Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need of serious help my Enter key just got damaged and I can no longer use the terminal properly. I split drink on my keyboard, all the keys work fine except for the enter key.

So i wanted to ask if the is any way I kind map it to a different key as I would or could do with Windows

Thanks for the help

share|improve this question
For a start, use Ctrl+m in the terminal. – August Karlstrom May 7 '13 at 11:29

You need to have two app: xev and xmodmap, both are commandline-tool.

Run xev. Then press the key whose behaviour you want to change. i.e. Enter. and then xev will output some information about the pressed key. Pay attention to the third line. It should be like this:

state 0x10, keycode 110 (keysym 0xff55, Prior), same_screen YES,

In this example Prior is the name of the behaviour the key is assigned to at the moment, the number keycode is the internal id to recognize the key. Now do this with another key i.e. PgDown give this output

state 0x10, keycode 115 (keysym 0xff56, Next), same_screen YES,

Here again the interesting part for us is keycode 115 and Next. Now, when you want to swap the two keys use xmodmap.

 xmodmap -e "keycode 110 = Next"

This changes the key with keycode 110 on your keyboard to the action Next. It's pretty simple.

share|improve this answer
@ castiblanco, noted but I believe my problem in fact is that the enter key can't be read by the computer, any command i enter is useless. any other way to handle this – Rock May 7 '13 at 11:47

How to press 'Enter' if the key does not work

If you are lucky to have a terminal open, press simultaneously Ctrl+Shift+U, then press Shift+A (uppercase A) to insert the Unicode for 'Enter'.

Otherwise you will have to use an on-screen keyboard (there may be one installed as an Accessibility tool) or use an external keyboard.

Remap key in X11 desktop

  1. Obtain the keycode of the key you want to remap by using the xev command.

    KeyRelease event, serial 34, synthetic NO, window 0x4a00001,
    root 0xc5, subw 0x0, time 482692681, (-95,23), root:(499,342),
    state 0x11, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
    XLookupString gives 0 bytes: 
    XFilterEvent returns: False

    Example output when pressing the right shift-key, which has keycode 62.

  2. Remap the desired keycode to Return using the xmodmap command, e.g.:

    xmodmap -e "keycode 62 = Return"

    Remaps keycode 62 from Shift_R to Return.

  3. When you are happy with your current keymap and want to use it in future X-sessions, run the following command to save it:

    xmodmap -pke > ~/.Xmodmap

Remap key in native Linux console

  1. Kernel keycodes are different from X11 ones. I found this keycode table in a quick Google search. I would choose R Shift which has the kernel keycode 54.
  2. Run the following command to dump your current keymap:

    dumpkeys > ~/keymap.dmp
  3. Now, modify the dumped keymap: You need to copy the behaviour of keycode 28 to the new keycode, i.e. keycode 54 if you want to use right-shift. You can do this manually in a text editor or use the following commands (copies behaviour from keycode 28 to keycode 54):

    sed -n '/keycode *28 = /p' ~/keymap.dmp > ~/keymap.return
    sed -i 's/28 =/54 =/' ~/keymap.return
    sed -e '/keycode *54 = /!b;r '$HOME'/keymap.return' -e 'd' ~/keymap.dmp > ~/

    Your new keymap is now in ~/

  4. Load your new keymap in the console (requires root access):

    sudo loadkeys ~/
  5. Happy about the result? On Ubuntu you can change the default keyboard settings in /etc/default/keyboard. Copy your modified keymap file to a safe location and find out how to load it automatically at startup, so you don't need to run loadkeys every time.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.