Tuesday, December 23, 2008

Remapping Menu key as Fn key

Info from following urls:
  http://humbledown.org/files/dunlug-keyboard-remap.pdf
  http://www.chuug.org/talks/tricks1a.pdf
  http://ubuntuforums.org/archive/index.php/t-820187.html
  http://www.linuxquestions.org/questions/linux-newbie-8/remapping-keys-using-xmodmap-home-key-652268/
  http://vim.wikia.com/wiki/Remap_the_Escape_key

    As mentioned in my previous post, I was trying to remap the Menu key as a Fn key. Well, I managed to do it, but it only works with the navigation keys. Eg.: Fn+Left=Home, Menu+Left=Home, Fn+Ins=PrtSc but Menu+Ins=nothing

    The command xmodmap was used to remap the Menu key as Mode_switch and the key mappings for the navigation keys were edited as well. A useful commandline utility I found was xev. It prints out the events in the X display system. Press Ctrl-Alt-T to open the terminal console and run "xev". If you press the Left key, you can see the keycode as 100 and the keysymname as Left. Now try with Fn+Left. Surprisingly, Fn has no keycode unlike the other modifier keys (Ctrl,Alt,Shift). Click in the terminal window and press Ctrl-C to exit. Now for xmodmap.

    Steps:
  1. Press Ctrl-Alt-T to open the terminal console.

  2. Type "sudo kwrite /usr/bin/remap-keys" to create a new bash script.

  3. Copy and paste the following into KWrite:

    #!/bin/bash

    # remap Menu key as a mode switch, like Fn
    # Need to remap Menu + up/down/left/right also
    # run xev to see info on each key pressed

    xmodmap -e "keycode 117 = Mode_switch"

    # = byItself withShift withModeSwitch
    xmodmap -e "keycode 100 = Left NoSymbol Home"
    xmodmap -e "keycode 102 = Right NoSymbol End"
    xmodmap -e "keycode 98 = Up NoSymbol Prior"
    xmodmap -e "keycode 104 = Down NoSymbol Next"

    xset -r 117 # Prevent the Menu key from autorepeating

  4. Save the file and exit back to the terminal console.

  5. Set the permissions to execute it by typing "sudo chmod 755 /usr/bin/remap-keys"

  6. Type "remap-keys" to run it. Use xev to test or try scrolling a document or webpage.

    If you wish to run it at startup, the fastest way would be to add "source /usr/bin/remap-keys" to the end of your .bashrc (see post on "Using Aliases to Make Life Easier").

    Keycode 117 is the keycode for the Menu key, gotten from running xev. Keycode 100 is the keycode for the Left key. The remapping "= Left NoSymbol Home" means when the Left key is pressed by itself, it means Left, Shift+Left=nothing, Mode_switch+Left=Home (in this case, Menu is our new Mode_switch key)

(^ v ^)

Saturday, December 20, 2008

Modifier keys

Info from following URLs:
  http://en.wikipedia.org/wiki/Computer_keyboard
  http://en.wikipedia.org/wiki/Windows_Key
  http://en.wikipedia.org/wiki/AltGr_key
  http://en.wikipedia.org/wiki/Space-cadet_keyboard

    I was surfing the Web last night on my Eee PC and thought that it would be easier to use the PgUp and PgDn keys if I could remap the Menu key as a Fn key. After searching around, I found info on xmodmap but could not understand what the Super-L and Hyper-L keys were.

    Did some "research" on our ubiquitous keyboard and decided to share the following info below, which will hopefully help in my quest to remap the keys later on :)

    This is a photo of my Fujitsu T4010 keyboard. I will be using the bottom row of keys to explain the special modifier keys. A modifier key when pressed in conjunction with another key, will perform a special operation (for example, Control-Alt-Delete) but rarely performs any function when pressed by itself.

(Bottom row, from left to right)
Key Description
Ctrl (left) ConTRoL key. A commonly used modifier key, so no elaboration here.
FnFunctioN key. This key is usually found on laptop keyboards and is used for various functions like adjusting volume, brightness, etc.
WinWINdows key.  Pressing and releasing it by itself opens the Start Menu in Windows, which can be invoked using Ctrl-Esc also.
Alt (left)ALTernate key. Commonly used to call up the application menu, eg. Alt-F to call up the File menu. The F10 key can be used to invoke the application menu as well.
SpacebarNot a modifier key, but the longest one on all keyboards :P
AltGrALTernate GRaphic key. On most keyboards, this functions as another Alt key. Used primarily to type characters unusual to the locale of the keyboard layout. If a key has a 3rd symbol on it, then AltGr can often be used to type it. As those using US keyboards increasingly needed the specific functionality of AltGr when typing non-English text, Windows began to allow all keystroke combinations involving AltGr to be typed by using Ctrl+Alt in its place. 
MenuAlso known as the Application key. Its primary function is to launch a context menu with the keyboard rather than with the usual right mouse button. This functionality can be invoked with the Shift-F10 shortcut also.
Ctrl (right)Typically, each keyboard will have 2 Ctrl keys, 2 Alt keys and 2 Win keys.


    This, is a Space-cadet keyboard used on MIT Lisp machines and designed by Tom Knight, which inspired several still-current jargon terms in the field of computer science and influenced the design of Emacs, a feature-rich text-editor popular with technically proficient computer users and computer programmers.

    It is said that with the combination of the Control, Meta, Hyper and Super keys, it was possible to type out over 8000 different characters on the Space-cadet keyboard, allowing users to type very complicated mathematical text. Many users were actually willing to memorise the command meanings of that many characters if it reduced typing time (this attitude shaped the interface of Emacs).

    The reason for showing this is that some keys in xmodmap are apparently linked to these, especially the Meta, Hyper and Super keys (on the left and right sides of the bottom row).
 
KeyDescription
HyperNot much info on this, except that it is a modifier key. 
SuperThis key is typically identified today with the Windows key or Apple logo key, although these may also be identified with the Meta key.
MetaSun keyboards continue to include it, marked as a solid diamond. May be considered equivalent to the Macintosh's command key. Emulated with Alt or Windows key on modern keyboards.
ComposeThe Compose key is not on the Space-cadet keyboard, but it's worth mentioning. Also known as the "Multi-key" on X Window System. A key designated to signal the software to interpret the subsequent keystrokes as a combination in order to produce a character not found on the keyboard.

(^ v ^)