Keymap config

From Qi-Hardware
Jump to: navigation, search

This article explains how to map keys at console-level.

Contents

[edit] Keyboard Handling

Nokia's QWS deals with keyboard handling. Once it gets an input, it checks for what keysym it maps to (looking at the keymap), and returns it. You can run 'env' to see an entry for your keyboard driver and its keymap. QWS uses Qmaps for keymaps, and keymaps can be converted to qmaps. All such info can be found here.

[edit] Configuration

Besides that, existing "load keys" utility lets you load keymaps too. You can write a keymap script of a few lines, and load it on top of existing keymap. I will briefly explain how to do such things.

$ showkey -k

will show you what the keycode for any key you press is. It should have an output like below. (I have experienced that if you do not press any key for a few seconds, the system will crash, so press the power-key once you are done.)

  keycode 37 press
  keycode 37 release

Lets find out what the existing functionality for that keycode is.

$ dumpkeys | grep 37
  keycode 37 = +k +K bracketright Contrel_k Control_k Meta_k Meta_Control_k five

"+" shows that the key can be "Shift"ed or "CapsLock"ed. By the way "k" "K" "bracketright" "Control_k" and such are called "keysym"s. You can view a list of keysyms with

$ dumpkeys -l

If you tested the 'dumpkeys -l' command, you would see that there are over 200 Function(F1,F2,F3...) keys. Those can be utilized to your liking. One such utility is to print a string.

$ loadkeys
  keycode 183 = F123
  string F12 = "Ben Rocks"

Now, if you press the 'ben' key (the one next to 'space'), it will automatically write 'Ben Rocks'

[edit] Sticky Keys, Modifier Locks

If you are like me, you are probably only using two fingers to type on Ben NanoNote, so; having to hold a finger on a modifier key (Shift, Ctrl, Alt, Fn, AltGr) can be bothersome.

  • Modifier Locks This enables you to use Modifier keys by toggling them (like Capslock).
  • Sticky Keys is like 'Modifier Locks', except it only works for the next key press.
  • Composing
$ loadkeys
  keymaps 0-15   #this line is needed. Don't know why...
  keycode 100 = AltGr_Lock
  keycode 42 = SShift

[edit] Accented keymaps

  • Hungarian: all NOT blue labelled keys on the nanonote keyboard - except the function keys - has an accented Hungarian character accessible width the fn button (with the benhu.kmap which is based on the keymaps_us_bnn.kmap - I only added the following lines and placed as /usr/share/kbd/keymap/i386/ben/benhu.kmap). The Hungarian characters works well in vim and on terminal).
ctrll keycode 32 = oacute #ó
ctrll keycode 33 = Oacute #Ó
ctrll keycode 34 = odiaeresis #ö
ctrll keycode 35 = Odiaeresis #Ö
ctrll keycode 47 = U+0151 #ő
ctrll keycode 48 = U+0150 #Ő
ctrll keycode 17 = egrave #
ctrll keycode 18 = eacute #é	
ctrll keycode 19 = Eacute #É
ctrll keycode 16 = agrave #
ctrll keycode 30 = aacute #á
ctrll keycode 31 = Aacute #Á	
ctrll keycode 20 = iacute #í
ctrll keycode 21 = Iacute #Í
ctrll keycode 40 = uacute #ú
ctrll keycode 51 = udiaeresis #ü
ctrll keycode 52 = U+0171 #ű
ctrll keycode 44 = Uacute #Ú
ctrll keycode 45 = Udiaeresis # Ü
ctrll keycode 46 = U+0170 # Ű

To activate the keymap and a readable font on startup, put these line in /etc/rc.local (after placing benhu.kmap to /usr/share/kbd/keymap/i386/ben/)

setfont /usr/share/kbd/consolefonts/ter-v14n.psf
loadkeys /usr/share/kbd/keymap/i386/ben/benhu.kmap

[edit] Article todo

  1. Compose
  2. Keyboard handling example
    1. write code [done]
    2. explain code [ ]
Personal tools
Namespaces
Variants
Actions
Navigation
interactive
Toolbox
Print/export