Bad keys
From Joyrex Wiki
Contents |
[edit]
Overview
Google around, there are a lot of issues with stuck keys. Mine is a bad CTRL key. I choose to replace Left Grab (really, the equivalent of the 'Windows' key on normal keyboards) with CTRL. I'm in Ubuntu, so you may have to change different files for a standard OLPC install.
Official OLPC Wiki Page on Stuck Keys
[edit]
Getting proper console keycodes
- Run showkey
- Press buttons, make the stuck key present itself. In my case I just had to sit there and it started spamming the hex code for CTRL (0x1d). Take that code.
- Go to a scientific calculator program, and put in the hex code without the beginning 0x. Then switch to decimal mode, and the calculator will convert to the decimal number needed. Use the decimal number below.
- Also press the button that you want to replace, take that hex value, and do the calculator conversion to decimal. Use this decimal number below.
[edit]
Console changes
- Add the following line to /etc/rc.local:
echo -ne "keymaps 0-15\nkeycode 125 = Control\nkeycode 29 =\n" | loadkeys
- Add the following line to the top of my local .bashrc (although I could probably just put it in the system-wide version):
echo -ne "keymaps 0-15\nkeycode 125 = Control\nkeycode 29 =\n" | sudo loadkeys
Note: This requires sudo access with the NOPASSWD option, otherwise you'll get prompted mid-login for your password again.
[edit]
Getting proper XWindows keycodes
- XWindows codes are different than the console ones.
- In XWindows, run xev from a terminal window. Keep the mouse over the box that comes up, then trigger the key problem. The key code is shown in the terminal window you ran xev from.
- Still in xev, press the key you want to replace. Make note of that keycode too.
- Close xev.
[edit]
XWindows changes
- If you run gdm, add the following lines to the bottom of /etc/gdm/Init/Default
xmodmap -e "remove Control = Control_L" xmodmap -e "keycode 37 = " xmodmap -e "keycode 115 = Control_L" xmodmap -e "add Control = Control_L"
- If you use a graphical login interface, add the following lines to the .xsession file in your home directory and select the "xsession" or "xclient" session:
xmodmap -e "remove Control = Control_L" xmodmap -e "keycode 37 = " xmodmap -e "keycode 115 = Control_L" xmodmap -e "add Control = Control_L"
Note: If you do it this way, you'll need to actually put the start command for your window manager at the bottom of .xsession, otherwise it won't know what to start. xfce4's is startxfce4
- If you don't use a graphical login interface, and just log in normally and use startx, put the following lines in your home directory's .xinitrc file:
xmodmap -e "remove Control = Control_L" xmodmap -e "keycode 37 = " xmodmap -e "keycode 115 = Control_L" xmodmap -e "add Control = Control_L"
Note: These must go before the start command for your window manager.
- If you run XFCE4, xfce4 may just totally ignore the .xinitrc or .xsession changes. Add them to the .xfce4_startup file:
xmodmap -e "remove Control = Control_L" xmodmap -e "keycode 37 = " xmodmap -e "keycode 115 = Control_L" xmodmap -e "add Control = Control_L"
- To do it manually, create a file called fix-xmodmap.sh and add the following lines. Then manually run this file when you want to:
xmodmap -e "remove Control = Control_L" xmodmap -e "keycode 37 = " xmodmap -e "keycode 115 = Control_L" xmodmap -e "add Control = Control_L"

