Home » 2014 » February » 19 » Shift Key is not working!! Mapping keyboard keys from one to another

2:27 PM
Shift Key is not working!! Mapping keyboard keys from one to another

Share on Google+

Lets see an example of mapping keyboard from one to other
 
Suppose your Shift key or Enter key is not working, you can use this command line help in Linux to solve this problem.
 
You can map any keys to any other key.. If your Enter key is not working you can map it to right shift key or any other key.
 
For this purpose, you need to use two command line utility
xev
xmodmap
 

XEV: This command is used to log the keyboard events. It starts an event tester and generates a log for every keys pressed on  the keyboard.

DESCRIPTION
 xev creates a window and then asks the X server to send it events whenever anything happens to the window (such as it being moved, resized, typed in, clicked in, etc.). You can also attach it to an existing  window. It is useful for seeing what causes events to occur and to display the information that they contain; it is essentially a debugging and development tool, and should not be needed in normal usage.


For eg. Below is the log of Shift key and Enter key. Notice the 3rd line which gives the keycode , the key pressed and the screen where pressed. 


KeyPress event, serial 23, synthetic NO, window 0x400001,
  root 0x54, subw 0x0, time 759929, (601,628), root:(605,654),
 
state 0x0, keycode 61 (keysym 0xffe2, Shift_R), same_screen YES,
  XLookupString gives 0 bytes:
  XmbLookupString gives 0 bytes:
  XFilterEvent returns: False

KeyRelease event, serial 25, synthetic NO, window 0x400001,
  root 0x54, subw 0x0, time 760088, (601,628), root:(605,654),
 
state 0x1, keycode 61 (keysym 0xffe2, Shift_R), same_screen YES,
  XLookupString gives 0 bytes:
  XFilterEvent returns: False

KeyPress event, serial 25, synthetic NO, window 0x400001,
 root 0x54, subw 0x0, time 761329, (601,628), root:(605,654),
 
state 0x0, keycode 35 (keysym 0xff0d, Return), same_screen YES,
 " XLookupString gives 1 bytes: (0d) "
 " XmbLookupString gives 1 bytes: (0d) "
  XFilterEvent returns: False

KeyRelease event, serial 25, synthetic NO, window 0x400001,
  root 0x54, subw 0x0, time 761469, (601,628), root:(605,654),
 
state 0x0, keycode 35 (keysym 0xff0d, Return), same_screen YES,
 " XLookupString gives 1 bytes: (0d) "

  XFilterEvent returns: False


XMODMAP:

This  command is used to remap the keyboard keys from one to another or as per user's choice. Suppose your Enter key is not working, you can use your right shift key by mapping Enter key to the it.

DESCRIPTION
 The xmodmap program is used to edit and display the keyboard modifier
  map and keymap table that are used by client applications to convert
  event keycodes into keysyms. It is usually run from the user's session 
startup script to configure the keyboard according to personal tastes.
 
So to map the right shift key to your enter key, use below command:

xmodmap -e "keycode 61=Return"
xmodmap -e "keycode 35=Shift_R"

  
 The format is: xmodmap -e EXPRESSION.

The expression can be:
                  keycode NUMBER=KEYSNAME
 
This mapping will persist only in the logged session, if you want it make it permanent, you have to execute below command.
 

xmodmap -pke >~/.Xmodmap

It will create a file Xmodmap in your home directory.
Then create one more file called .xinitrc in your home directory where you have to enter this line:

 xmodmap .Xmodmap
 
So, You are done. Now your right shift key will function as Enter key.
 
 
 

Category: Open System-Linux | Views: 5746 | Added by: shanky | Tags: shift key not working, mapping of keyboard keys, xmodmap, enter key not working, xev | Rating: 0.0/0

Related blogs


You may also like to see:


[2014-03-13][Open System-Linux]
crontab: A command in linux to automatically start/repeat a process at certian time and interval
[2014-11-25][Open System-Linux]
DMESG command in Linux : to display or control kernel ring buffer
[2015-09-09][Open System-Linux]
Some funny and cool commands in Linux
[2016-12-11][Open System-Linux]
Some great usage and example of find command in Linux
[2017-08-13][Open System-Linux]
Perl trick to remove Ctrl - M charater from a file

Total comments: 0
ComForm">
avatar