LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Remapping shift&ctrl keys kills key repetition (http://www.linuxquestions.org/questions/linux-desktop-74/remapping-shift-and-ctrl-keys-kills-key-repetition-788607/)

nitro2k01 02-11-2010 11:49 PM

Remapping shift&ctrl keys kills key repetition
 
I have a laptop where the enter and up arrow keys are physically broken. I have been able to solve this with the following commands:
Code:

xmodmap -e "remove shift = Shift_R"
xmodmap -e "keycode  62 = KP_Up KP_8 KP_Up KP_8 KP_Up KP_8"
xmodmap -e "remove control = Control_R"
xmodmap -e "keycode 105 = KP_Enter NoSymbol KP_Enter NoSymbol KP_Enter"

That code remaps RCtrl to enter and RShift to up arrow.
This code does work, but it has a minor flaw. When holding either of the keys, there are no repeated key presses. Is there any way to solve this through configuration alone? (Ie, not by modifying source code)

Related questions:
1) What is the best way to apply this configuration? Is there a configuration files for these mappings? (Right now I have a shell script that gets run on each X startup)
2) Any pointers as to how one can remap keys outside of X?

nitro2k01 02-12-2010 12:45 AM

I actually managed to solve it myself. The solution was to use xset r for the relevant keycodes. I should also point out the commands above contain an error. The "up" line actually makes shift up produce the character 8. (I guess I copied it from the numpad 8 key definition :) ) So my final script looks like this:
Code:

xmodmap -e "remove shift = Shift_R"
xmodmap -e "keycode  62 = KP_Up KP_Up KP_Up KP_Up KP_Up"
xmodmap -e "remove control = Control_R"
xmodmap -e "keycode 105 = KP_Enter NoSymbol KP_Enter NoSymbol KP_Enter"
xset r 62
xset r 105

Still looking for an answer to my additional questions.

DavidMcCann 02-13-2010 12:56 PM

The alternative to an xmodmap script is more complicated and only worth doing for major alterations. You'd need to alter
/usr/share/X11/xkb/symbols/pc
/usr/share/X11/xkb/symbols/keypad

For running without X, there doesn't seem to be an alternative to altering files. Look in
/lib/kbd/keymaps/i386/include/linux-keys-bare.inc
/lib/kbd/keymaps/i386/qwerty/uk.map.gz (or ..us..., or whatever)
and it's all there somewhere.


All times are GMT -5. The time now is 12:58 AM.