Archive for the ‘Tinkering’ Category

Keyboard fun

Sunday, March 20th, 2011

One can have hours of fun with xmodmap. Especially if one has a Symbolics keyboard.

For a start, I get a “real” Meta key (not Alt) and a couple of extra modifier keys that emacs knows about: Hyper and Super. I mapped these to mod2 and mod3. Staying away from mod4 is a good idea because that defaults to the Windows key (on modern keyboards) and there are some Gnome shortcuts that would clash, e.g. show desktop (Windows-d). Modifier 5 is known by xmodmap as Mode_switch, normally mapped to “Alt Gr”.

I learned that a keypress can do 4 things according to the mode it’s in:

  • normal press – type the glyph
  • shift + press – type the shifted glyph
  • mode_switch + press
  • shift + mode_switch + press

The last two of these are outside of normal use, which basically means that you are free to map them to whatever. On the Symbolics keyboard I mapped mode_switch to the Symbol key. Then I had fun making the modmap to make the keys do various things like type Greek letters and mathematical symbols.

I think there’s a reasonably natural mapping between Greek and English letters thus:

  • A – alpha (α)
  • B – beta (β)
  • C – chi (χ)
  • D – delta (δ)
  • E – epsilon (ε)
  • F – phi (φ)
  • G – gamma (γ)
  • H – theta (θ)
  • I – iota (ι)
  • K – kappa (κ)
  • L – lambda (λ)
  • M – mu (μ)
  • N – eta (η)
  • O – omicron (ο)
  • P – pi (π)
  • R – rho (ρ)
  • S – sigma (σ)
  • T – tau (τ)
  • U – upsilon (υ)
  • V – nu (ν)
  • W – omega (ω)
  • X – xi (ξ)
  • Y – psi (ψ)
  • Z – zeta (ζ)

That leaves Q and J free with no obvious Greek letter equivalents. For the number keys, I added some mathematical symbols, and for the punctuation keys I added further punctuation (e.g. left and right guillemots) and things like copyright and trademark symbols.

But that’s not all… I have plans to alter the keyboard firmware (it’s just programmed using C and Teensy – I’ve already made some mods) to use the “Mode Lock” key more extensively. So Mode Lock basically is a hardware shift key, and when it’s on, I can make the entire keyboard send different key codes. Since there are a total of 255 possible keycodes recognisable by xmodmap, I should have room to fit in another complete set (again, 4 per key) and be able to type all sorts of weird and wonderful glyphs.

The only issue I have at the moment is around the keycodes that are in the “numpad zone” on a regular keyboard. The mode_switch doesn’t seem to work with them yet. I still have to figure that out.