How do I remap certain keys or devices?How can I remap keyboard keys?Ubuntu equivalent of Karbiner for Mac?grave accent key is not workingHow to change one key in the keyboard?Remapping only 1 key to anotherDown Arrow Key is not workingMy “a” key is busted. I want to map to another keyHow to map right windows key to backspace?how to get xbd recognisedPermanent key swapping and disabling methodHow do I remap the Caps Lock and Ctrl keys?Remap keys like viRemap function keys to commands?Swap F keys to perform functions without Fn keyHow to remap an unknown keyfn+pgup (home) button key in Fujitsu Lifebook PH521 is not working on Ubuntu 14.04-01How do I remap keys in ubuntu?Map Fn+Direction Keys to Home, End, etcChrome disabled key remapped with xkbHow to remap thinkpad Keyboard(F11) and Favorites(F12) keys?

Why don't airports use arresting gears to recover energy from landing passenger planes?

How To Make Earth's Oceans as Brackish as Lyr's

What 68-pin connector is this on my 2.5" solid state drive?

What is the Radroute bicycle path?

If I'm saying that something is two adjectives and one uses "ser" but the other uses "estar", what should I do?

What is the mathematical notation for rounding a given number to the nearest integer?

What is the source of "You can achieve a lot with hate, but even more with love" (Shakespeare?)

Seven Places at Once - Another Google Earth Challenge?

Are space camera sensors usually round, or square?

How does a simple logistic regression model achieve a 92% classification accuracy on MNIST?

Amortized Loans seem to benefit the bank more than the customer

What makes a smart phone "kosher"?

How to draw a Venn diagram for X - (Y intersect Z)?

Are there any “Third Order” acronyms used in space exploration?

Why is the UK still pressing on with Brexit?

Some Prime Peerage

How would you control supersoldiers in a late iron-age society?

How to control the output voltage of a solid state relay

How to give my students a straightedge instead of a ruler

What would happen if Protagoras v Euathlus were heard in court today?

Is the Dodge action perceptible to other characters?

shell script to check if input is a string/integer/float

If I want an interpretable model, are there methods other than Linear Regression?

Bash awk command with quotes



How do I remap certain keys or devices?


How can I remap keyboard keys?Ubuntu equivalent of Karbiner for Mac?grave accent key is not workingHow to change one key in the keyboard?Remapping only 1 key to anotherDown Arrow Key is not workingMy “a” key is busted. I want to map to another keyHow to map right windows key to backspace?how to get xbd recognisedPermanent key swapping and disabling methodHow do I remap the Caps Lock and Ctrl keys?Remap keys like viRemap function keys to commands?Swap F keys to perform functions without Fn keyHow to remap an unknown keyfn+pgup (home) button key in Fujitsu Lifebook PH521 is not working on Ubuntu 14.04-01How do I remap keys in ubuntu?Map Fn+Direction Keys to Home, End, etcChrome disabled key remapped with xkbHow to remap thinkpad Keyboard(F11) and Favorites(F12) keys?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








235















I'm searching for a way to remap certain keys in ubuntu.



i.e.



I'd like to change PgUp to Home or PgDown to End.



Does a built-in command or a tool exist reassign keys in Ubuntu/GNOME?










share|improve this question


























  • checkout my answer here. It doesn't worth copy and paste same answer. Perhaps it would help you.

    – Rahul Virpara
    Jun 2 '12 at 9:40






  • 1





    Any Emacs-like bindings here for CTRL-P/N for unit steps?

    – Léo Léopold Hertz 준영
    Jul 7 '15 at 13:12











  • Since some time xmodmap is depricated! to get a system wide setting you have to use xkb. So edit the language file in /usr/share/X11/xkb/symbols/ to add your changes there. See askubuntu.com/a/898462/34298

    – rubo77
    Mar 30 '17 at 21:48

















235















I'm searching for a way to remap certain keys in ubuntu.



i.e.



I'd like to change PgUp to Home or PgDown to End.



Does a built-in command or a tool exist reassign keys in Ubuntu/GNOME?










share|improve this question


























  • checkout my answer here. It doesn't worth copy and paste same answer. Perhaps it would help you.

    – Rahul Virpara
    Jun 2 '12 at 9:40






  • 1





    Any Emacs-like bindings here for CTRL-P/N for unit steps?

    – Léo Léopold Hertz 준영
    Jul 7 '15 at 13:12











  • Since some time xmodmap is depricated! to get a system wide setting you have to use xkb. So edit the language file in /usr/share/X11/xkb/symbols/ to add your changes there. See askubuntu.com/a/898462/34298

    – rubo77
    Mar 30 '17 at 21:48













235












235








235


127






I'm searching for a way to remap certain keys in ubuntu.



i.e.



I'd like to change PgUp to Home or PgDown to End.



Does a built-in command or a tool exist reassign keys in Ubuntu/GNOME?










share|improve this question
















I'm searching for a way to remap certain keys in ubuntu.



i.e.



I'd like to change PgUp to Home or PgDown to End.



Does a built-in command or a tool exist reassign keys in Ubuntu/GNOME?







xorg keyboard shortcut-keys






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 14 '14 at 8:53









Tim

21k17 gold badges92 silver badges148 bronze badges




21k17 gold badges92 silver badges148 bronze badges










asked Feb 5 '11 at 13:20









NESNES

14.7k37 gold badges91 silver badges115 bronze badges




14.7k37 gold badges91 silver badges115 bronze badges















  • checkout my answer here. It doesn't worth copy and paste same answer. Perhaps it would help you.

    – Rahul Virpara
    Jun 2 '12 at 9:40






  • 1





    Any Emacs-like bindings here for CTRL-P/N for unit steps?

    – Léo Léopold Hertz 준영
    Jul 7 '15 at 13:12











  • Since some time xmodmap is depricated! to get a system wide setting you have to use xkb. So edit the language file in /usr/share/X11/xkb/symbols/ to add your changes there. See askubuntu.com/a/898462/34298

    – rubo77
    Mar 30 '17 at 21:48

















  • checkout my answer here. It doesn't worth copy and paste same answer. Perhaps it would help you.

    – Rahul Virpara
    Jun 2 '12 at 9:40






  • 1





    Any Emacs-like bindings here for CTRL-P/N for unit steps?

    – Léo Léopold Hertz 준영
    Jul 7 '15 at 13:12











  • Since some time xmodmap is depricated! to get a system wide setting you have to use xkb. So edit the language file in /usr/share/X11/xkb/symbols/ to add your changes there. See askubuntu.com/a/898462/34298

    – rubo77
    Mar 30 '17 at 21:48
















checkout my answer here. It doesn't worth copy and paste same answer. Perhaps it would help you.

– Rahul Virpara
Jun 2 '12 at 9:40





checkout my answer here. It doesn't worth copy and paste same answer. Perhaps it would help you.

– Rahul Virpara
Jun 2 '12 at 9:40




1




1





Any Emacs-like bindings here for CTRL-P/N for unit steps?

– Léo Léopold Hertz 준영
Jul 7 '15 at 13:12





Any Emacs-like bindings here for CTRL-P/N for unit steps?

– Léo Léopold Hertz 준영
Jul 7 '15 at 13:12













Since some time xmodmap is depricated! to get a system wide setting you have to use xkb. So edit the language file in /usr/share/X11/xkb/symbols/ to add your changes there. See askubuntu.com/a/898462/34298

– rubo77
Mar 30 '17 at 21:48





Since some time xmodmap is depricated! to get a system wide setting you have to use xkb. So edit the language file in /usr/share/X11/xkb/symbols/ to add your changes there. See askubuntu.com/a/898462/34298

– rubo77
Mar 30 '17 at 21:48










8 Answers
8






active

oldest

votes


















249
















Notice: As of 2013, Ubuntu and derivatives no longer use xmodmap, but instead use xkb. For more information see this answer. The answer below is no longer relevant for current releases.




For remapping certain keys you need two tools. First xev (command-line tool) and second xmodmap (also command-line tool). Both should be available in Ubuntu without extra installing them.



  1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.



  2. xev will output some information about the pressed key. The third line is important. It should look similar to:



    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 - the name of the behaviour.




  3. 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.



    Note that if the key you are mapping should have a different meaning when used with the Shift key (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:



     xmodmap -e "keycode 53 = backslash bar"


Additional information: The sequence of these mappings is Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key. To skip a column use NoSymbol. Moreover, here is a comprehensive list of all keysyms.



Note: These change are for the active X session only and will be lost after reboot.
When you want to save the changes permanently you have to run the following commands after the ones above:



xmodmap -pke >~/.Xmodmap


(it creates a file named .Xmodmap in your home directory (~))



Then you have to create a file named .xinitrc in your home directory where you put command xmodmap .Xmodmap in.



You can now modify .Xmodmap and run xmodmap .Xmodmap from console to see the changes immediately. The changes in .Xmodmap will persist.



source: Ubuntu Foruns



Bonus stuff:



If the key you are remapping has different behavior depending on a state (
like how the keys in the numeric keyboard depend on NumLock) you simply have to do xmodmap -pm to get a list of modifiers and then do:



xmodmap -e "KEYCODE MODIFIER = behaviour behaviour_with_modifier"



Suppose, for example, that you want to get a period instead of a comma on the numeric keyboard (useful for most programmers), but you want to keep the "delete" behavior when NumLock is off.



xmodmap -e "keycode 91 mod2 = KP_Delete period"


mod2, because xmodmap -pm tells us that mod2 is Num_Lock, the other names are obtained by pressing the keys in xev.






share|improve this answer






















  • 3





    xev is not able to catch Fn key pressings

    – om-nom-nom
    Feb 15 '12 at 15:08






  • 3





    The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

    – Allyl Isocyanate
    Oct 10 '12 at 19:17






  • 1





    If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

    – stommestack
    Jun 27 '13 at 17:10






  • 1





    Strange, I did everything, but my keymappings still reset after restarting.

    – Costa
    Dec 27 '13 at 3:39






  • 1





    I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

    – isomorphismes
    Feb 17 '14 at 14:47


















20
















If you're trying to move a Shift key, there are a few extra steps:



 xmodmap -e "keycode 62 = Up" # Shift => Up
xmodmap -e "keycode 111 = Shift_R" # Up => Shift
xmodmap -e "add shift = Shift_R" # Make the new Shift key actually do shifting
xmodmap -e "remove shift = Up" # Prevent the old Shift key from shifting
xset r 62 # Make the new Up key autorepeat
xset -r 111 # Prevent the new Shift key from autorepeating





share|improve this answer

























  • +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

    – rbrito
    Jan 6 '13 at 8:47






  • 2





    An important answer for users using keyboards on Lenovo Laptops

    – Einar Ólafsson
    May 1 '17 at 15:38


















16
















I've just had an afterthought.. I think you may mean something entirely different by "remap".. but I'll leave my answer as it is... (I don't know how to re-assign one key to behave as another)



UPDATE: my 'afterthought' has been confirmed; ( I've answered the wrong question :)... please see NES's Community Wiki answer (accepted above).



There are two general ways to remap rebind a key.



  • locally to a particular program

    (a key can be used for different things in different apps/windows)

  • globally for a specific user

    (a key has the same function in all windows)

For 'local to a program' methods, there is sometimes a way to change keybindings offered by the app itself... eg.



Firefox has an addon called keyconfig ... for some info see this MozillZine post



Most Ubuntu programs are Gnome based and there is a specific utility to modify the keybinding for any menu item of these Gnome apps... It is called Editable Menu Accelerator ... It is a very 'touchy' tool, but quite powerful.. You can enable it by running gconf-editor (via Terminal or Alt+F2)... navigate to desktop--gnome--interface and select can_change_accels .... You can then change menu items to virtual anything you like (per program/window)... I suggest you disable it as soon as you've done what you need..



Otherwise you can set up Global hotkeys. I use a program called xbindkeys Install xbindkeys, and there is also an option available via the Main Menu -- Preferences, called Keyboard Shortcuts



If you use xbindkeys, you will need to add it to your "Startup Applications" (Main Menu -- Preferences) ... Also (as suggested by Stefano Palazzo) I have previously written a more detailed description of xbindkeys in an answer on this askubuntu page






share|improve this answer



























  • +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

    – Stefano Palazzo
    Feb 5 '11 at 14:17






  • 1





    The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

    – Stefano Palazzo
    Feb 5 '11 at 14:24











  • i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

    – NES
    Feb 5 '11 at 14:28












  • @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

    – Peter.O
    Feb 5 '11 at 14:52











  • yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

    – NES
    Feb 5 '11 at 15:42


















9
















Here is how I tried to switch the mapping of the ENTER key to the SHIFT key
(and vice versa):



$ uname -a


REPORTS:



Linux box 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

$ which xmodmap


REPORTS:



/usr/bin/xmodmap

$ which xev


REPORTS:



/usr/bin/xev

$ xev


(ignore the next fifty lines or so)



PRESS THE ENTER KEY (notice the third line):
KeyPress event, serial 33, synthetic NO, window 0x5600001,
root 0x110, subw 0x0, time 263441120, (738,242), root:(771,314),
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d)
XmbLookupString gives 1 bytes: (0d)
XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x5600001,
root 0x110, subw 0x0, time 263441271, (738,242), root:(771,314),
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d)
XFilterEvent returns: False

PRESS THE SHIFT KEY (notice the third line):
KeyPress event, serial 30, synthetic NO, window 0x5600001,
root 0x110, subw 0x0, time 263592202, (464,368), root:(497,440),
state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False

KeyRelease event, serial 33, synthetic NO, window 0x5600001,
root 0x110, subw 0x0, time 263592298, (464,368), root:(497,440),
state 0x1, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False


What's important is the third line of each keypress:



FOR:
state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
The name "Return" is the name of the behavior of the key pressed.
The number of the key pressed is "36".

state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
The name "Shift_R" is the name of the behavior of the key pressed.
The number of the key pressed is "62".


REVERSE THE MAPPING:



$ xmodmap -e "keycode 62 = Return"
$ xmodmap -e "keycode 36 = Shift_R"


SAVE THE RESULTS:



$ xmodmap -pke > ~/.Xmodmap
$ vi ~/.xinitrc


ADD



 xmodmap ~/.Xmodmap

$ sudo reboot


The main problem was that the reversal did NOT work.
The ENTER key was mapped to the SHIFT_R key; but the SHIFT_R key was not mapped to the ENTER key. Go figure.






share|improve this answer


































    7
















    In order to do global remaps independently of X, you can make use of console-setup(5) instead.



    In my case I wanted to remap Caps Lock key to D, since my D-key is broken :)



    First I used dumpkeys(1) to get a template for a mapping, in the case of the D-key, the interesting bit is the mapping for keycode 32 (on my keyboard); Note that there are two spaces in the grep pattern!



    $ sudo dumpkeys | grep "keycode 32" > tempfile
    $ cat tempfile
    keycode 32 = +d
    shift keycode 32 = +D
    altgr keycode 32 = +eth
    shift altgr keycode 32 = +ETH
    control keycode 32 = Control_d
    shift control keycode 32 = Control_d
    altgr control keycode 32 = Control_d
    shift altgr control keycode 32 = Control_d
    (121 lines total...)


    In order to change the map to apply to Caps Lock (keycode 58 on my keyboard) instead



    sed 's/32/58/' -i tempfile


    Now it reads



    keycode 58 = +d
    shift keycode 58 = +D
    altgr keycode 58 = +eth
    (etc...)


    To add this remap to the default map, it simply needs to be appended to the remap include file for console-setup



    sudo sh -c 'cat tempfile >> /etc/console-setup/remap.inc'


    and console-setup needs to be reconfigured (skipping low priority questions with -phigh)



    sudo dpkg-reconfigure console-setup -phigh


    Now the remap should be completed, and be loaded automatically on boot.






    share|improve this answer


































      3
















      I spent one whole day in trying to create a shortcut for Ctrl+Pageup.



      I first tried xmodmap but that can't generate modifier events. So it is impossible to create a shortcut that generates for example the Control event.



      I then tried xbindkeys with xmacro. That sort of works, but xbindkeys is not able to capture some key combinations on my system, such as Alt + ___.



      So I finally used Unity's own Keyboard Shortcuts -> Custom Shortcuts to setup my shortcut.



      And instead of xmacro, I have now used xvkbd program to generate the keyboard events, but that is just a personal preference. Both xmacro and xvkbd work almost the same. One additional tip is to add a delay parameter in xmacro or xvkbd to ensure that the events don't get lost.






      share|improve this answer
































        2
















        For me AutoKey from Software Center worked the best. It has intuitive GUI, to add new binding click New -> Phrase and



        1. Add name, click OK

        2. At "Phrase Settings" section make sure the paste using is set to keyboard

        3. Add hotkey that you want to use

        4. Add command into text field, eg to emulate left arrow key - it'd be <left> (list of special keys is here).





        share|improve this answer

























        • This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

          – Ben
          Mar 20 at 23:06












        • However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

          – Ben
          Mar 20 at 23:30











        • @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

          – bruddha
          Mar 24 at 8:05


















        0
















        If you need to remap a key for a specific program only, I've just added this feature to hax11.




        I'd like to change PgUp to Home or PgDown to End.




        To do this with hax11, open the program's profile configuration file under ~/.config/hax11/profiles (e.g. ~/.config/hax11/profiles/usrlibfirefoxfirefox), and add:



        Enable=1
        MapK112=K110
        MapK117=K115





        share|improve this answer



























          protected by Seth Mar 10 '14 at 21:07



          Thank you for your interest in this question.
          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



          Would you like to answer one of these unanswered questions instead?














          8 Answers
          8






          active

          oldest

          votes








          8 Answers
          8






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          249
















          Notice: As of 2013, Ubuntu and derivatives no longer use xmodmap, but instead use xkb. For more information see this answer. The answer below is no longer relevant for current releases.




          For remapping certain keys you need two tools. First xev (command-line tool) and second xmodmap (also command-line tool). Both should be available in Ubuntu without extra installing them.



          1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.



          2. xev will output some information about the pressed key. The third line is important. It should look similar to:



            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 - the name of the behaviour.




          3. 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.



            Note that if the key you are mapping should have a different meaning when used with the Shift key (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:



             xmodmap -e "keycode 53 = backslash bar"


          Additional information: The sequence of these mappings is Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key. To skip a column use NoSymbol. Moreover, here is a comprehensive list of all keysyms.



          Note: These change are for the active X session only and will be lost after reboot.
          When you want to save the changes permanently you have to run the following commands after the ones above:



          xmodmap -pke >~/.Xmodmap


          (it creates a file named .Xmodmap in your home directory (~))



          Then you have to create a file named .xinitrc in your home directory where you put command xmodmap .Xmodmap in.



          You can now modify .Xmodmap and run xmodmap .Xmodmap from console to see the changes immediately. The changes in .Xmodmap will persist.



          source: Ubuntu Foruns



          Bonus stuff:



          If the key you are remapping has different behavior depending on a state (
          like how the keys in the numeric keyboard depend on NumLock) you simply have to do xmodmap -pm to get a list of modifiers and then do:



          xmodmap -e "KEYCODE MODIFIER = behaviour behaviour_with_modifier"



          Suppose, for example, that you want to get a period instead of a comma on the numeric keyboard (useful for most programmers), but you want to keep the "delete" behavior when NumLock is off.



          xmodmap -e "keycode 91 mod2 = KP_Delete period"


          mod2, because xmodmap -pm tells us that mod2 is Num_Lock, the other names are obtained by pressing the keys in xev.






          share|improve this answer






















          • 3





            xev is not able to catch Fn key pressings

            – om-nom-nom
            Feb 15 '12 at 15:08






          • 3





            The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

            – Allyl Isocyanate
            Oct 10 '12 at 19:17






          • 1





            If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

            – stommestack
            Jun 27 '13 at 17:10






          • 1





            Strange, I did everything, but my keymappings still reset after restarting.

            – Costa
            Dec 27 '13 at 3:39






          • 1





            I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

            – isomorphismes
            Feb 17 '14 at 14:47















          249
















          Notice: As of 2013, Ubuntu and derivatives no longer use xmodmap, but instead use xkb. For more information see this answer. The answer below is no longer relevant for current releases.




          For remapping certain keys you need two tools. First xev (command-line tool) and second xmodmap (also command-line tool). Both should be available in Ubuntu without extra installing them.



          1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.



          2. xev will output some information about the pressed key. The third line is important. It should look similar to:



            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 - the name of the behaviour.




          3. 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.



            Note that if the key you are mapping should have a different meaning when used with the Shift key (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:



             xmodmap -e "keycode 53 = backslash bar"


          Additional information: The sequence of these mappings is Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key. To skip a column use NoSymbol. Moreover, here is a comprehensive list of all keysyms.



          Note: These change are for the active X session only and will be lost after reboot.
          When you want to save the changes permanently you have to run the following commands after the ones above:



          xmodmap -pke >~/.Xmodmap


          (it creates a file named .Xmodmap in your home directory (~))



          Then you have to create a file named .xinitrc in your home directory where you put command xmodmap .Xmodmap in.



          You can now modify .Xmodmap and run xmodmap .Xmodmap from console to see the changes immediately. The changes in .Xmodmap will persist.



          source: Ubuntu Foruns



          Bonus stuff:



          If the key you are remapping has different behavior depending on a state (
          like how the keys in the numeric keyboard depend on NumLock) you simply have to do xmodmap -pm to get a list of modifiers and then do:



          xmodmap -e "KEYCODE MODIFIER = behaviour behaviour_with_modifier"



          Suppose, for example, that you want to get a period instead of a comma on the numeric keyboard (useful for most programmers), but you want to keep the "delete" behavior when NumLock is off.



          xmodmap -e "keycode 91 mod2 = KP_Delete period"


          mod2, because xmodmap -pm tells us that mod2 is Num_Lock, the other names are obtained by pressing the keys in xev.






          share|improve this answer






















          • 3





            xev is not able to catch Fn key pressings

            – om-nom-nom
            Feb 15 '12 at 15:08






          • 3





            The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

            – Allyl Isocyanate
            Oct 10 '12 at 19:17






          • 1





            If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

            – stommestack
            Jun 27 '13 at 17:10






          • 1





            Strange, I did everything, but my keymappings still reset after restarting.

            – Costa
            Dec 27 '13 at 3:39






          • 1





            I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

            – isomorphismes
            Feb 17 '14 at 14:47













          249














          249










          249









          Notice: As of 2013, Ubuntu and derivatives no longer use xmodmap, but instead use xkb. For more information see this answer. The answer below is no longer relevant for current releases.




          For remapping certain keys you need two tools. First xev (command-line tool) and second xmodmap (also command-line tool). Both should be available in Ubuntu without extra installing them.



          1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.



          2. xev will output some information about the pressed key. The third line is important. It should look similar to:



            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 - the name of the behaviour.




          3. 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.



            Note that if the key you are mapping should have a different meaning when used with the Shift key (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:



             xmodmap -e "keycode 53 = backslash bar"


          Additional information: The sequence of these mappings is Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key. To skip a column use NoSymbol. Moreover, here is a comprehensive list of all keysyms.



          Note: These change are for the active X session only and will be lost after reboot.
          When you want to save the changes permanently you have to run the following commands after the ones above:



          xmodmap -pke >~/.Xmodmap


          (it creates a file named .Xmodmap in your home directory (~))



          Then you have to create a file named .xinitrc in your home directory where you put command xmodmap .Xmodmap in.



          You can now modify .Xmodmap and run xmodmap .Xmodmap from console to see the changes immediately. The changes in .Xmodmap will persist.



          source: Ubuntu Foruns



          Bonus stuff:



          If the key you are remapping has different behavior depending on a state (
          like how the keys in the numeric keyboard depend on NumLock) you simply have to do xmodmap -pm to get a list of modifiers and then do:



          xmodmap -e "KEYCODE MODIFIER = behaviour behaviour_with_modifier"



          Suppose, for example, that you want to get a period instead of a comma on the numeric keyboard (useful for most programmers), but you want to keep the "delete" behavior when NumLock is off.



          xmodmap -e "keycode 91 mod2 = KP_Delete period"


          mod2, because xmodmap -pm tells us that mod2 is Num_Lock, the other names are obtained by pressing the keys in xev.






          share|improve this answer















          Notice: As of 2013, Ubuntu and derivatives no longer use xmodmap, but instead use xkb. For more information see this answer. The answer below is no longer relevant for current releases.




          For remapping certain keys you need two tools. First xev (command-line tool) and second xmodmap (also command-line tool). Both should be available in Ubuntu without extra installing them.



          1. Start terminal window and run xev. Now it's active and waits for you to press a key. Then press the key whose behaviour you want to change. i.e. PgUp.



          2. xev will output some information about the pressed key. The third line is important. It should look similar to:



            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 - the name of the behaviour.




          3. 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.



            Note that if the key you are mapping should have a different meaning when used with the Shift key (for example for British keyboard layouts, Shift+2 gives quotation marks) then you can simply list the secondary command after the first. For example if you want the key with code 53 to map to backslash normally, but to the bar symbol when used with shift, you might do:



             xmodmap -e "keycode 53 = backslash bar"


          Additional information: The sequence of these mappings is Key, Shift+Key, mode_switch+Key, mode_switch+Shift+Key, AltGr+Key, AltGr+Shift+Key. To skip a column use NoSymbol. Moreover, here is a comprehensive list of all keysyms.



          Note: These change are for the active X session only and will be lost after reboot.
          When you want to save the changes permanently you have to run the following commands after the ones above:



          xmodmap -pke >~/.Xmodmap


          (it creates a file named .Xmodmap in your home directory (~))



          Then you have to create a file named .xinitrc in your home directory where you put command xmodmap .Xmodmap in.



          You can now modify .Xmodmap and run xmodmap .Xmodmap from console to see the changes immediately. The changes in .Xmodmap will persist.



          source: Ubuntu Foruns



          Bonus stuff:



          If the key you are remapping has different behavior depending on a state (
          like how the keys in the numeric keyboard depend on NumLock) you simply have to do xmodmap -pm to get a list of modifiers and then do:



          xmodmap -e "KEYCODE MODIFIER = behaviour behaviour_with_modifier"



          Suppose, for example, that you want to get a period instead of a comma on the numeric keyboard (useful for most programmers), but you want to keep the "delete" behavior when NumLock is off.



          xmodmap -e "keycode 91 mod2 = KP_Delete period"


          mod2, because xmodmap -pm tells us that mod2 is Num_Lock, the other names are obtained by pressing the keys in xev.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Feb 8 '15 at 10:17


























          community wiki





          13 revs, 10 users 53%
          NES











          • 3





            xev is not able to catch Fn key pressings

            – om-nom-nom
            Feb 15 '12 at 15:08






          • 3





            The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

            – Allyl Isocyanate
            Oct 10 '12 at 19:17






          • 1





            If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

            – stommestack
            Jun 27 '13 at 17:10






          • 1





            Strange, I did everything, but my keymappings still reset after restarting.

            – Costa
            Dec 27 '13 at 3:39






          • 1





            I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

            – isomorphismes
            Feb 17 '14 at 14:47












          • 3





            xev is not able to catch Fn key pressings

            – om-nom-nom
            Feb 15 '12 at 15:08






          • 3





            The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

            – Allyl Isocyanate
            Oct 10 '12 at 19:17






          • 1





            If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

            – stommestack
            Jun 27 '13 at 17:10






          • 1





            Strange, I did everything, but my keymappings still reset after restarting.

            – Costa
            Dec 27 '13 at 3:39






          • 1





            I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

            – isomorphismes
            Feb 17 '14 at 14:47







          3




          3





          xev is not able to catch Fn key pressings

          – om-nom-nom
          Feb 15 '12 at 15:08





          xev is not able to catch Fn key pressings

          – om-nom-nom
          Feb 15 '12 at 15:08




          3




          3





          The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

          – Allyl Isocyanate
          Oct 10 '12 at 19:17





          The selected answer didn't work for remapping the Caps-lock key for me on Ubuntu 12.10. I was able to to do this by going to System Settings -> Keyboard -> Layout Settings -> Options, which has a list of keys and alternative behaviors. Worked flawlessly in Unity and terminal.

          – Allyl Isocyanate
          Oct 10 '12 at 19:17




          1




          1





          If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

          – stommestack
          Jun 27 '13 at 17:10





          If you have multiple keyboards connected, will these tools see a difference between the same key on another keyboard?

          – stommestack
          Jun 27 '13 at 17:10




          1




          1





          Strange, I did everything, but my keymappings still reset after restarting.

          – Costa
          Dec 27 '13 at 3:39





          Strange, I did everything, but my keymappings still reset after restarting.

          – Costa
          Dec 27 '13 at 3:39




          1




          1





          I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

          – isomorphismes
          Feb 17 '14 at 14:47





          I don't think I have an -event flag in Ubuntu 12.04. It throws an error and doesn't mention "event" in man xev.

          – isomorphismes
          Feb 17 '14 at 14:47













          20
















          If you're trying to move a Shift key, there are a few extra steps:



           xmodmap -e "keycode 62 = Up" # Shift => Up
          xmodmap -e "keycode 111 = Shift_R" # Up => Shift
          xmodmap -e "add shift = Shift_R" # Make the new Shift key actually do shifting
          xmodmap -e "remove shift = Up" # Prevent the old Shift key from shifting
          xset r 62 # Make the new Up key autorepeat
          xset -r 111 # Prevent the new Shift key from autorepeating





          share|improve this answer

























          • +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

            – rbrito
            Jan 6 '13 at 8:47






          • 2





            An important answer for users using keyboards on Lenovo Laptops

            – Einar Ólafsson
            May 1 '17 at 15:38















          20
















          If you're trying to move a Shift key, there are a few extra steps:



           xmodmap -e "keycode 62 = Up" # Shift => Up
          xmodmap -e "keycode 111 = Shift_R" # Up => Shift
          xmodmap -e "add shift = Shift_R" # Make the new Shift key actually do shifting
          xmodmap -e "remove shift = Up" # Prevent the old Shift key from shifting
          xset r 62 # Make the new Up key autorepeat
          xset -r 111 # Prevent the new Shift key from autorepeating





          share|improve this answer

























          • +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

            – rbrito
            Jan 6 '13 at 8:47






          • 2





            An important answer for users using keyboards on Lenovo Laptops

            – Einar Ólafsson
            May 1 '17 at 15:38













          20














          20










          20









          If you're trying to move a Shift key, there are a few extra steps:



           xmodmap -e "keycode 62 = Up" # Shift => Up
          xmodmap -e "keycode 111 = Shift_R" # Up => Shift
          xmodmap -e "add shift = Shift_R" # Make the new Shift key actually do shifting
          xmodmap -e "remove shift = Up" # Prevent the old Shift key from shifting
          xset r 62 # Make the new Up key autorepeat
          xset -r 111 # Prevent the new Shift key from autorepeating





          share|improve this answer













          If you're trying to move a Shift key, there are a few extra steps:



           xmodmap -e "keycode 62 = Up" # Shift => Up
          xmodmap -e "keycode 111 = Shift_R" # Up => Shift
          xmodmap -e "add shift = Shift_R" # Make the new Shift key actually do shifting
          xmodmap -e "remove shift = Up" # Prevent the old Shift key from shifting
          xset r 62 # Make the new Up key autorepeat
          xset -r 111 # Prevent the new Shift key from autorepeating






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 17 '12 at 18:46









          cmcgintycmcginty

          2,8265 gold badges25 silver badges31 bronze badges




          2,8265 gold badges25 silver badges31 bronze badges















          • +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

            – rbrito
            Jan 6 '13 at 8:47






          • 2





            An important answer for users using keyboards on Lenovo Laptops

            – Einar Ólafsson
            May 1 '17 at 15:38

















          • +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

            – rbrito
            Jan 6 '13 at 8:47






          • 2





            An important answer for users using keyboards on Lenovo Laptops

            – Einar Ólafsson
            May 1 '17 at 15:38
















          +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

          – rbrito
          Jan 6 '13 at 8:47





          +1 The most unix-y answer of all of those for a modifier (I had already done so way, way back with my iBook 2, when I wanted the enter key to have the function of Control_R, but had forgotten the details).

          – rbrito
          Jan 6 '13 at 8:47




          2




          2





          An important answer for users using keyboards on Lenovo Laptops

          – Einar Ólafsson
          May 1 '17 at 15:38





          An important answer for users using keyboards on Lenovo Laptops

          – Einar Ólafsson
          May 1 '17 at 15:38











          16
















          I've just had an afterthought.. I think you may mean something entirely different by "remap".. but I'll leave my answer as it is... (I don't know how to re-assign one key to behave as another)



          UPDATE: my 'afterthought' has been confirmed; ( I've answered the wrong question :)... please see NES's Community Wiki answer (accepted above).



          There are two general ways to remap rebind a key.



          • locally to a particular program

            (a key can be used for different things in different apps/windows)

          • globally for a specific user

            (a key has the same function in all windows)

          For 'local to a program' methods, there is sometimes a way to change keybindings offered by the app itself... eg.



          Firefox has an addon called keyconfig ... for some info see this MozillZine post



          Most Ubuntu programs are Gnome based and there is a specific utility to modify the keybinding for any menu item of these Gnome apps... It is called Editable Menu Accelerator ... It is a very 'touchy' tool, but quite powerful.. You can enable it by running gconf-editor (via Terminal or Alt+F2)... navigate to desktop--gnome--interface and select can_change_accels .... You can then change menu items to virtual anything you like (per program/window)... I suggest you disable it as soon as you've done what you need..



          Otherwise you can set up Global hotkeys. I use a program called xbindkeys Install xbindkeys, and there is also an option available via the Main Menu -- Preferences, called Keyboard Shortcuts



          If you use xbindkeys, you will need to add it to your "Startup Applications" (Main Menu -- Preferences) ... Also (as suggested by Stefano Palazzo) I have previously written a more detailed description of xbindkeys in an answer on this askubuntu page






          share|improve this answer



























          • +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

            – Stefano Palazzo
            Feb 5 '11 at 14:17






          • 1





            The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

            – Stefano Palazzo
            Feb 5 '11 at 14:24











          • i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

            – NES
            Feb 5 '11 at 14:28












          • @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

            – Peter.O
            Feb 5 '11 at 14:52











          • yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

            – NES
            Feb 5 '11 at 15:42















          16
















          I've just had an afterthought.. I think you may mean something entirely different by "remap".. but I'll leave my answer as it is... (I don't know how to re-assign one key to behave as another)



          UPDATE: my 'afterthought' has been confirmed; ( I've answered the wrong question :)... please see NES's Community Wiki answer (accepted above).



          There are two general ways to remap rebind a key.



          • locally to a particular program

            (a key can be used for different things in different apps/windows)

          • globally for a specific user

            (a key has the same function in all windows)

          For 'local to a program' methods, there is sometimes a way to change keybindings offered by the app itself... eg.



          Firefox has an addon called keyconfig ... for some info see this MozillZine post



          Most Ubuntu programs are Gnome based and there is a specific utility to modify the keybinding for any menu item of these Gnome apps... It is called Editable Menu Accelerator ... It is a very 'touchy' tool, but quite powerful.. You can enable it by running gconf-editor (via Terminal or Alt+F2)... navigate to desktop--gnome--interface and select can_change_accels .... You can then change menu items to virtual anything you like (per program/window)... I suggest you disable it as soon as you've done what you need..



          Otherwise you can set up Global hotkeys. I use a program called xbindkeys Install xbindkeys, and there is also an option available via the Main Menu -- Preferences, called Keyboard Shortcuts



          If you use xbindkeys, you will need to add it to your "Startup Applications" (Main Menu -- Preferences) ... Also (as suggested by Stefano Palazzo) I have previously written a more detailed description of xbindkeys in an answer on this askubuntu page






          share|improve this answer



























          • +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

            – Stefano Palazzo
            Feb 5 '11 at 14:17






          • 1





            The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

            – Stefano Palazzo
            Feb 5 '11 at 14:24











          • i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

            – NES
            Feb 5 '11 at 14:28












          • @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

            – Peter.O
            Feb 5 '11 at 14:52











          • yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

            – NES
            Feb 5 '11 at 15:42













          16














          16










          16









          I've just had an afterthought.. I think you may mean something entirely different by "remap".. but I'll leave my answer as it is... (I don't know how to re-assign one key to behave as another)



          UPDATE: my 'afterthought' has been confirmed; ( I've answered the wrong question :)... please see NES's Community Wiki answer (accepted above).



          There are two general ways to remap rebind a key.



          • locally to a particular program

            (a key can be used for different things in different apps/windows)

          • globally for a specific user

            (a key has the same function in all windows)

          For 'local to a program' methods, there is sometimes a way to change keybindings offered by the app itself... eg.



          Firefox has an addon called keyconfig ... for some info see this MozillZine post



          Most Ubuntu programs are Gnome based and there is a specific utility to modify the keybinding for any menu item of these Gnome apps... It is called Editable Menu Accelerator ... It is a very 'touchy' tool, but quite powerful.. You can enable it by running gconf-editor (via Terminal or Alt+F2)... navigate to desktop--gnome--interface and select can_change_accels .... You can then change menu items to virtual anything you like (per program/window)... I suggest you disable it as soon as you've done what you need..



          Otherwise you can set up Global hotkeys. I use a program called xbindkeys Install xbindkeys, and there is also an option available via the Main Menu -- Preferences, called Keyboard Shortcuts



          If you use xbindkeys, you will need to add it to your "Startup Applications" (Main Menu -- Preferences) ... Also (as suggested by Stefano Palazzo) I have previously written a more detailed description of xbindkeys in an answer on this askubuntu page






          share|improve this answer















          I've just had an afterthought.. I think you may mean something entirely different by "remap".. but I'll leave my answer as it is... (I don't know how to re-assign one key to behave as another)



          UPDATE: my 'afterthought' has been confirmed; ( I've answered the wrong question :)... please see NES's Community Wiki answer (accepted above).



          There are two general ways to remap rebind a key.



          • locally to a particular program

            (a key can be used for different things in different apps/windows)

          • globally for a specific user

            (a key has the same function in all windows)

          For 'local to a program' methods, there is sometimes a way to change keybindings offered by the app itself... eg.



          Firefox has an addon called keyconfig ... for some info see this MozillZine post



          Most Ubuntu programs are Gnome based and there is a specific utility to modify the keybinding for any menu item of these Gnome apps... It is called Editable Menu Accelerator ... It is a very 'touchy' tool, but quite powerful.. You can enable it by running gconf-editor (via Terminal or Alt+F2)... navigate to desktop--gnome--interface and select can_change_accels .... You can then change menu items to virtual anything you like (per program/window)... I suggest you disable it as soon as you've done what you need..



          Otherwise you can set up Global hotkeys. I use a program called xbindkeys Install xbindkeys, and there is also an option available via the Main Menu -- Preferences, called Keyboard Shortcuts



          If you use xbindkeys, you will need to add it to your "Startup Applications" (Main Menu -- Preferences) ... Also (as suggested by Stefano Palazzo) I have previously written a more detailed description of xbindkeys in an answer on this askubuntu page







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 13 '17 at 12:24









          Community

          1




          1










          answered Feb 5 '11 at 14:04









          Peter.OPeter.O

          11.6k26 gold badges99 silver badges154 bronze badges




          11.6k26 gold badges99 silver badges154 bronze badges















          • +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

            – Stefano Palazzo
            Feb 5 '11 at 14:17






          • 1





            The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

            – Stefano Palazzo
            Feb 5 '11 at 14:24











          • i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

            – NES
            Feb 5 '11 at 14:28












          • @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

            – Peter.O
            Feb 5 '11 at 14:52











          • yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

            – NES
            Feb 5 '11 at 15:42

















          • +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

            – Stefano Palazzo
            Feb 5 '11 at 14:17






          • 1





            The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

            – Stefano Palazzo
            Feb 5 '11 at 14:24











          • i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

            – NES
            Feb 5 '11 at 14:28












          • @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

            – Peter.O
            Feb 5 '11 at 14:52











          • yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

            – NES
            Feb 5 '11 at 15:42
















          +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

          – Stefano Palazzo
          Feb 5 '11 at 14:17





          +1, very nice! A suggestion: You should integrate your great answer from another question into this one, maybe also explain the configuration format of xbindkeys a little bit.

          – Stefano Palazzo
          Feb 5 '11 at 14:17




          1




          1





          The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

          – Stefano Palazzo
          Feb 5 '11 at 14:24





          The bit about assigning other keys could be handled by xdotool, check out the man page, I've used it to solve this problem.

          – Stefano Palazzo
          Feb 5 '11 at 14:24













          i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

          – NES
          Feb 5 '11 at 14:28






          i recently found another approach with a tool called xmodmap in combination with a tool called xev. i don't know what the differences between xmodmap and xbindkeys are, but this works pretty well for me. some advice with tool to prefer of the named two? Here is a very helpful step by step guide which describes xmodmap and xev ubuntuforums.org/showpost.php?p=7675138&postcount=2

          – NES
          Feb 5 '11 at 14:28














          @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

          – Peter.O
          Feb 5 '11 at 14:52





          @NES.. It appears I've addressed the wrong point.. You seem to want to actually remap the way a particular key is interpreted by the OS, ie, a non-standard keyboard interpretation, whereas I've been refering to a standard keyboard-interpretation, and simply overloading the default key-assignments. (I think what you are after is similar to swapping the left and right mouse buttons) .. Well it seems my answer was good for the wrong thing :)

          – Peter.O
          Feb 5 '11 at 14:52













          yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

          – NES
          Feb 5 '11 at 15:42





          yes, but no problem. the answer is also interesting. the step by step guide i posted the link above was the right way. so i'll post a short answer with the solution that other users have a good guide. thanks fred

          – NES
          Feb 5 '11 at 15:42











          9
















          Here is how I tried to switch the mapping of the ENTER key to the SHIFT key
          (and vice versa):



          $ uname -a


          REPORTS:



          Linux box 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

          $ which xmodmap


          REPORTS:



          /usr/bin/xmodmap

          $ which xev


          REPORTS:



          /usr/bin/xev

          $ xev


          (ignore the next fifty lines or so)



          PRESS THE ENTER KEY (notice the third line):
          KeyPress event, serial 33, synthetic NO, window 0x5600001,
          root 0x110, subw 0x0, time 263441120, (738,242), root:(771,314),
          state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
          XLookupString gives 1 bytes: (0d)
          XmbLookupString gives 1 bytes: (0d)
          XFilterEvent returns: False

          KeyRelease event, serial 33, synthetic NO, window 0x5600001,
          root 0x110, subw 0x0, time 263441271, (738,242), root:(771,314),
          state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
          XLookupString gives 1 bytes: (0d)
          XFilterEvent returns: False

          PRESS THE SHIFT KEY (notice the third line):
          KeyPress event, serial 30, synthetic NO, window 0x5600001,
          root 0x110, subw 0x0, time 263592202, (464,368), root:(497,440),
          state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
          XLookupString gives 0 bytes:
          XmbLookupString gives 0 bytes:
          XFilterEvent returns: False

          KeyRelease event, serial 33, synthetic NO, window 0x5600001,
          root 0x110, subw 0x0, time 263592298, (464,368), root:(497,440),
          state 0x1, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
          XLookupString gives 0 bytes:
          XFilterEvent returns: False


          What's important is the third line of each keypress:



          FOR:
          state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
          The name "Return" is the name of the behavior of the key pressed.
          The number of the key pressed is "36".

          state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
          The name "Shift_R" is the name of the behavior of the key pressed.
          The number of the key pressed is "62".


          REVERSE THE MAPPING:



          $ xmodmap -e "keycode 62 = Return"
          $ xmodmap -e "keycode 36 = Shift_R"


          SAVE THE RESULTS:



          $ xmodmap -pke > ~/.Xmodmap
          $ vi ~/.xinitrc


          ADD



           xmodmap ~/.Xmodmap

          $ sudo reboot


          The main problem was that the reversal did NOT work.
          The ENTER key was mapped to the SHIFT_R key; but the SHIFT_R key was not mapped to the ENTER key. Go figure.






          share|improve this answer































            9
















            Here is how I tried to switch the mapping of the ENTER key to the SHIFT key
            (and vice versa):



            $ uname -a


            REPORTS:



            Linux box 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

            $ which xmodmap


            REPORTS:



            /usr/bin/xmodmap

            $ which xev


            REPORTS:



            /usr/bin/xev

            $ xev


            (ignore the next fifty lines or so)



            PRESS THE ENTER KEY (notice the third line):
            KeyPress event, serial 33, synthetic NO, window 0x5600001,
            root 0x110, subw 0x0, time 263441120, (738,242), root:(771,314),
            state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
            XLookupString gives 1 bytes: (0d)
            XmbLookupString gives 1 bytes: (0d)
            XFilterEvent returns: False

            KeyRelease event, serial 33, synthetic NO, window 0x5600001,
            root 0x110, subw 0x0, time 263441271, (738,242), root:(771,314),
            state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
            XLookupString gives 1 bytes: (0d)
            XFilterEvent returns: False

            PRESS THE SHIFT KEY (notice the third line):
            KeyPress event, serial 30, synthetic NO, window 0x5600001,
            root 0x110, subw 0x0, time 263592202, (464,368), root:(497,440),
            state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
            XLookupString gives 0 bytes:
            XmbLookupString gives 0 bytes:
            XFilterEvent returns: False

            KeyRelease event, serial 33, synthetic NO, window 0x5600001,
            root 0x110, subw 0x0, time 263592298, (464,368), root:(497,440),
            state 0x1, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
            XLookupString gives 0 bytes:
            XFilterEvent returns: False


            What's important is the third line of each keypress:



            FOR:
            state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
            The name "Return" is the name of the behavior of the key pressed.
            The number of the key pressed is "36".

            state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
            The name "Shift_R" is the name of the behavior of the key pressed.
            The number of the key pressed is "62".


            REVERSE THE MAPPING:



            $ xmodmap -e "keycode 62 = Return"
            $ xmodmap -e "keycode 36 = Shift_R"


            SAVE THE RESULTS:



            $ xmodmap -pke > ~/.Xmodmap
            $ vi ~/.xinitrc


            ADD



             xmodmap ~/.Xmodmap

            $ sudo reboot


            The main problem was that the reversal did NOT work.
            The ENTER key was mapped to the SHIFT_R key; but the SHIFT_R key was not mapped to the ENTER key. Go figure.






            share|improve this answer





























              9














              9










              9









              Here is how I tried to switch the mapping of the ENTER key to the SHIFT key
              (and vice versa):



              $ uname -a


              REPORTS:



              Linux box 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

              $ which xmodmap


              REPORTS:



              /usr/bin/xmodmap

              $ which xev


              REPORTS:



              /usr/bin/xev

              $ xev


              (ignore the next fifty lines or so)



              PRESS THE ENTER KEY (notice the third line):
              KeyPress event, serial 33, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263441120, (738,242), root:(771,314),
              state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
              XLookupString gives 1 bytes: (0d)
              XmbLookupString gives 1 bytes: (0d)
              XFilterEvent returns: False

              KeyRelease event, serial 33, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263441271, (738,242), root:(771,314),
              state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
              XLookupString gives 1 bytes: (0d)
              XFilterEvent returns: False

              PRESS THE SHIFT KEY (notice the third line):
              KeyPress event, serial 30, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263592202, (464,368), root:(497,440),
              state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
              XLookupString gives 0 bytes:
              XmbLookupString gives 0 bytes:
              XFilterEvent returns: False

              KeyRelease event, serial 33, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263592298, (464,368), root:(497,440),
              state 0x1, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
              XLookupString gives 0 bytes:
              XFilterEvent returns: False


              What's important is the third line of each keypress:



              FOR:
              state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
              The name "Return" is the name of the behavior of the key pressed.
              The number of the key pressed is "36".

              state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
              The name "Shift_R" is the name of the behavior of the key pressed.
              The number of the key pressed is "62".


              REVERSE THE MAPPING:



              $ xmodmap -e "keycode 62 = Return"
              $ xmodmap -e "keycode 36 = Shift_R"


              SAVE THE RESULTS:



              $ xmodmap -pke > ~/.Xmodmap
              $ vi ~/.xinitrc


              ADD



               xmodmap ~/.Xmodmap

              $ sudo reboot


              The main problem was that the reversal did NOT work.
              The ENTER key was mapped to the SHIFT_R key; but the SHIFT_R key was not mapped to the ENTER key. Go figure.






              share|improve this answer















              Here is how I tried to switch the mapping of the ENTER key to the SHIFT key
              (and vice versa):



              $ uname -a


              REPORTS:



              Linux box 2.6.32-37-generic #81-Ubuntu SMP Fri Dec 2 20:35:14 UTC 2011 i686 GNU/Linux

              $ which xmodmap


              REPORTS:



              /usr/bin/xmodmap

              $ which xev


              REPORTS:



              /usr/bin/xev

              $ xev


              (ignore the next fifty lines or so)



              PRESS THE ENTER KEY (notice the third line):
              KeyPress event, serial 33, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263441120, (738,242), root:(771,314),
              state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
              XLookupString gives 1 bytes: (0d)
              XmbLookupString gives 1 bytes: (0d)
              XFilterEvent returns: False

              KeyRelease event, serial 33, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263441271, (738,242), root:(771,314),
              state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
              XLookupString gives 1 bytes: (0d)
              XFilterEvent returns: False

              PRESS THE SHIFT KEY (notice the third line):
              KeyPress event, serial 30, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263592202, (464,368), root:(497,440),
              state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
              XLookupString gives 0 bytes:
              XmbLookupString gives 0 bytes:
              XFilterEvent returns: False

              KeyRelease event, serial 33, synthetic NO, window 0x5600001,
              root 0x110, subw 0x0, time 263592298, (464,368), root:(497,440),
              state 0x1, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
              XLookupString gives 0 bytes:
              XFilterEvent returns: False


              What's important is the third line of each keypress:



              FOR:
              state 0x0, keycode 36 (keysym 0xff0d, Return), same_screen YES,
              The name "Return" is the name of the behavior of the key pressed.
              The number of the key pressed is "36".

              state 0x0, keycode 62 (keysym 0xffe2, Shift_R), same_screen YES,
              The name "Shift_R" is the name of the behavior of the key pressed.
              The number of the key pressed is "62".


              REVERSE THE MAPPING:



              $ xmodmap -e "keycode 62 = Return"
              $ xmodmap -e "keycode 36 = Shift_R"


              SAVE THE RESULTS:



              $ xmodmap -pke > ~/.Xmodmap
              $ vi ~/.xinitrc


              ADD



               xmodmap ~/.Xmodmap

              $ sudo reboot


              The main problem was that the reversal did NOT work.
              The ENTER key was mapped to the SHIFT_R key; but the SHIFT_R key was not mapped to the ENTER key. Go figure.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Oct 16 '12 at 14:56









              henrique

              3173 silver badges14 bronze badges




              3173 silver badges14 bronze badges










              answered Jan 27 '12 at 3:04









              Bill DavisBill Davis

              911 silver badge1 bronze badge




              911 silver badge1 bronze badge
























                  7
















                  In order to do global remaps independently of X, you can make use of console-setup(5) instead.



                  In my case I wanted to remap Caps Lock key to D, since my D-key is broken :)



                  First I used dumpkeys(1) to get a template for a mapping, in the case of the D-key, the interesting bit is the mapping for keycode 32 (on my keyboard); Note that there are two spaces in the grep pattern!



                  $ sudo dumpkeys | grep "keycode 32" > tempfile
                  $ cat tempfile
                  keycode 32 = +d
                  shift keycode 32 = +D
                  altgr keycode 32 = +eth
                  shift altgr keycode 32 = +ETH
                  control keycode 32 = Control_d
                  shift control keycode 32 = Control_d
                  altgr control keycode 32 = Control_d
                  shift altgr control keycode 32 = Control_d
                  (121 lines total...)


                  In order to change the map to apply to Caps Lock (keycode 58 on my keyboard) instead



                  sed 's/32/58/' -i tempfile


                  Now it reads



                  keycode 58 = +d
                  shift keycode 58 = +D
                  altgr keycode 58 = +eth
                  (etc...)


                  To add this remap to the default map, it simply needs to be appended to the remap include file for console-setup



                  sudo sh -c 'cat tempfile >> /etc/console-setup/remap.inc'


                  and console-setup needs to be reconfigured (skipping low priority questions with -phigh)



                  sudo dpkg-reconfigure console-setup -phigh


                  Now the remap should be completed, and be loaded automatically on boot.






                  share|improve this answer































                    7
















                    In order to do global remaps independently of X, you can make use of console-setup(5) instead.



                    In my case I wanted to remap Caps Lock key to D, since my D-key is broken :)



                    First I used dumpkeys(1) to get a template for a mapping, in the case of the D-key, the interesting bit is the mapping for keycode 32 (on my keyboard); Note that there are two spaces in the grep pattern!



                    $ sudo dumpkeys | grep "keycode 32" > tempfile
                    $ cat tempfile
                    keycode 32 = +d
                    shift keycode 32 = +D
                    altgr keycode 32 = +eth
                    shift altgr keycode 32 = +ETH
                    control keycode 32 = Control_d
                    shift control keycode 32 = Control_d
                    altgr control keycode 32 = Control_d
                    shift altgr control keycode 32 = Control_d
                    (121 lines total...)


                    In order to change the map to apply to Caps Lock (keycode 58 on my keyboard) instead



                    sed 's/32/58/' -i tempfile


                    Now it reads



                    keycode 58 = +d
                    shift keycode 58 = +D
                    altgr keycode 58 = +eth
                    (etc...)


                    To add this remap to the default map, it simply needs to be appended to the remap include file for console-setup



                    sudo sh -c 'cat tempfile >> /etc/console-setup/remap.inc'


                    and console-setup needs to be reconfigured (skipping low priority questions with -phigh)



                    sudo dpkg-reconfigure console-setup -phigh


                    Now the remap should be completed, and be loaded automatically on boot.






                    share|improve this answer





























                      7














                      7










                      7









                      In order to do global remaps independently of X, you can make use of console-setup(5) instead.



                      In my case I wanted to remap Caps Lock key to D, since my D-key is broken :)



                      First I used dumpkeys(1) to get a template for a mapping, in the case of the D-key, the interesting bit is the mapping for keycode 32 (on my keyboard); Note that there are two spaces in the grep pattern!



                      $ sudo dumpkeys | grep "keycode 32" > tempfile
                      $ cat tempfile
                      keycode 32 = +d
                      shift keycode 32 = +D
                      altgr keycode 32 = +eth
                      shift altgr keycode 32 = +ETH
                      control keycode 32 = Control_d
                      shift control keycode 32 = Control_d
                      altgr control keycode 32 = Control_d
                      shift altgr control keycode 32 = Control_d
                      (121 lines total...)


                      In order to change the map to apply to Caps Lock (keycode 58 on my keyboard) instead



                      sed 's/32/58/' -i tempfile


                      Now it reads



                      keycode 58 = +d
                      shift keycode 58 = +D
                      altgr keycode 58 = +eth
                      (etc...)


                      To add this remap to the default map, it simply needs to be appended to the remap include file for console-setup



                      sudo sh -c 'cat tempfile >> /etc/console-setup/remap.inc'


                      and console-setup needs to be reconfigured (skipping low priority questions with -phigh)



                      sudo dpkg-reconfigure console-setup -phigh


                      Now the remap should be completed, and be loaded automatically on boot.






                      share|improve this answer















                      In order to do global remaps independently of X, you can make use of console-setup(5) instead.



                      In my case I wanted to remap Caps Lock key to D, since my D-key is broken :)



                      First I used dumpkeys(1) to get a template for a mapping, in the case of the D-key, the interesting bit is the mapping for keycode 32 (on my keyboard); Note that there are two spaces in the grep pattern!



                      $ sudo dumpkeys | grep "keycode 32" > tempfile
                      $ cat tempfile
                      keycode 32 = +d
                      shift keycode 32 = +D
                      altgr keycode 32 = +eth
                      shift altgr keycode 32 = +ETH
                      control keycode 32 = Control_d
                      shift control keycode 32 = Control_d
                      altgr control keycode 32 = Control_d
                      shift altgr control keycode 32 = Control_d
                      (121 lines total...)


                      In order to change the map to apply to Caps Lock (keycode 58 on my keyboard) instead



                      sed 's/32/58/' -i tempfile


                      Now it reads



                      keycode 58 = +d
                      shift keycode 58 = +D
                      altgr keycode 58 = +eth
                      (etc...)


                      To add this remap to the default map, it simply needs to be appended to the remap include file for console-setup



                      sudo sh -c 'cat tempfile >> /etc/console-setup/remap.inc'


                      and console-setup needs to be reconfigured (skipping low priority questions with -phigh)



                      sudo dpkg-reconfigure console-setup -phigh


                      Now the remap should be completed, and be loaded automatically on boot.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Jan 9 '14 at 12:09


























                      community wiki





                      4 revs
                      arand

























                          3
















                          I spent one whole day in trying to create a shortcut for Ctrl+Pageup.



                          I first tried xmodmap but that can't generate modifier events. So it is impossible to create a shortcut that generates for example the Control event.



                          I then tried xbindkeys with xmacro. That sort of works, but xbindkeys is not able to capture some key combinations on my system, such as Alt + ___.



                          So I finally used Unity's own Keyboard Shortcuts -> Custom Shortcuts to setup my shortcut.



                          And instead of xmacro, I have now used xvkbd program to generate the keyboard events, but that is just a personal preference. Both xmacro and xvkbd work almost the same. One additional tip is to add a delay parameter in xmacro or xvkbd to ensure that the events don't get lost.






                          share|improve this answer





























                            3
















                            I spent one whole day in trying to create a shortcut for Ctrl+Pageup.



                            I first tried xmodmap but that can't generate modifier events. So it is impossible to create a shortcut that generates for example the Control event.



                            I then tried xbindkeys with xmacro. That sort of works, but xbindkeys is not able to capture some key combinations on my system, such as Alt + ___.



                            So I finally used Unity's own Keyboard Shortcuts -> Custom Shortcuts to setup my shortcut.



                            And instead of xmacro, I have now used xvkbd program to generate the keyboard events, but that is just a personal preference. Both xmacro and xvkbd work almost the same. One additional tip is to add a delay parameter in xmacro or xvkbd to ensure that the events don't get lost.






                            share|improve this answer



























                              3














                              3










                              3









                              I spent one whole day in trying to create a shortcut for Ctrl+Pageup.



                              I first tried xmodmap but that can't generate modifier events. So it is impossible to create a shortcut that generates for example the Control event.



                              I then tried xbindkeys with xmacro. That sort of works, but xbindkeys is not able to capture some key combinations on my system, such as Alt + ___.



                              So I finally used Unity's own Keyboard Shortcuts -> Custom Shortcuts to setup my shortcut.



                              And instead of xmacro, I have now used xvkbd program to generate the keyboard events, but that is just a personal preference. Both xmacro and xvkbd work almost the same. One additional tip is to add a delay parameter in xmacro or xvkbd to ensure that the events don't get lost.






                              share|improve this answer













                              I spent one whole day in trying to create a shortcut for Ctrl+Pageup.



                              I first tried xmodmap but that can't generate modifier events. So it is impossible to create a shortcut that generates for example the Control event.



                              I then tried xbindkeys with xmacro. That sort of works, but xbindkeys is not able to capture some key combinations on my system, such as Alt + ___.



                              So I finally used Unity's own Keyboard Shortcuts -> Custom Shortcuts to setup my shortcut.



                              And instead of xmacro, I have now used xvkbd program to generate the keyboard events, but that is just a personal preference. Both xmacro and xvkbd work almost the same. One additional tip is to add a delay parameter in xmacro or xvkbd to ensure that the events don't get lost.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jan 20 '14 at 5:30









                              HRJHRJ

                              3442 silver badges15 bronze badges




                              3442 silver badges15 bronze badges
























                                  2
















                                  For me AutoKey from Software Center worked the best. It has intuitive GUI, to add new binding click New -> Phrase and



                                  1. Add name, click OK

                                  2. At "Phrase Settings" section make sure the paste using is set to keyboard

                                  3. Add hotkey that you want to use

                                  4. Add command into text field, eg to emulate left arrow key - it'd be <left> (list of special keys is here).





                                  share|improve this answer

























                                  • This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

                                    – Ben
                                    Mar 20 at 23:06












                                  • However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

                                    – Ben
                                    Mar 20 at 23:30











                                  • @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

                                    – bruddha
                                    Mar 24 at 8:05















                                  2
















                                  For me AutoKey from Software Center worked the best. It has intuitive GUI, to add new binding click New -> Phrase and



                                  1. Add name, click OK

                                  2. At "Phrase Settings" section make sure the paste using is set to keyboard

                                  3. Add hotkey that you want to use

                                  4. Add command into text field, eg to emulate left arrow key - it'd be <left> (list of special keys is here).





                                  share|improve this answer

























                                  • This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

                                    – Ben
                                    Mar 20 at 23:06












                                  • However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

                                    – Ben
                                    Mar 20 at 23:30











                                  • @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

                                    – bruddha
                                    Mar 24 at 8:05













                                  2














                                  2










                                  2









                                  For me AutoKey from Software Center worked the best. It has intuitive GUI, to add new binding click New -> Phrase and



                                  1. Add name, click OK

                                  2. At "Phrase Settings" section make sure the paste using is set to keyboard

                                  3. Add hotkey that you want to use

                                  4. Add command into text field, eg to emulate left arrow key - it'd be <left> (list of special keys is here).





                                  share|improve this answer













                                  For me AutoKey from Software Center worked the best. It has intuitive GUI, to add new binding click New -> Phrase and



                                  1. Add name, click OK

                                  2. At "Phrase Settings" section make sure the paste using is set to keyboard

                                  3. Add hotkey that you want to use

                                  4. Add command into text field, eg to emulate left arrow key - it'd be <left> (list of special keys is here).






                                  share|improve this answer












                                  share|improve this answer



                                  share|improve this answer










                                  answered Jul 28 '18 at 12:15









                                  bruddhabruddha

                                  1781 silver badge7 bronze badges




                                  1781 silver badge7 bronze badges















                                  • This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

                                    – Ben
                                    Mar 20 at 23:06












                                  • However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

                                    – Ben
                                    Mar 20 at 23:30











                                  • @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

                                    – bruddha
                                    Mar 24 at 8:05

















                                  • This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

                                    – Ben
                                    Mar 20 at 23:06












                                  • However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

                                    – Ben
                                    Mar 20 at 23:30











                                  • @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

                                    – bruddha
                                    Mar 24 at 8:05
















                                  This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

                                  – Ben
                                  Mar 20 at 23:06






                                  This worked perfekt to set up Super+C and Super+V to Ctrl+C and Ctrl+V . Just the perfect solution when using Ubuntu via VirtualBox on a mac

                                  – Ben
                                  Mar 20 at 23:06














                                  However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

                                  – Ben
                                  Mar 20 at 23:30





                                  However, this does not disable other commands that listen to these shortcuts. To disable Super+V to "show the notification list" go to Setting -> Devices -> Keyboard and disable it there

                                  – Ben
                                  Mar 20 at 23:30













                                  @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

                                  – bruddha
                                  Mar 24 at 8:05





                                  @Ben yup, it would be great if it displayed bindings of other apps, but it's rather icing on the cake. My problem is that it's not possible to remap "Fn" key. I've decided to try out uhk keyboard - that thing programmable independent of os, will see how it goes.

                                  – bruddha
                                  Mar 24 at 8:05











                                  0
















                                  If you need to remap a key for a specific program only, I've just added this feature to hax11.




                                  I'd like to change PgUp to Home or PgDown to End.




                                  To do this with hax11, open the program's profile configuration file under ~/.config/hax11/profiles (e.g. ~/.config/hax11/profiles/usrlibfirefoxfirefox), and add:



                                  Enable=1
                                  MapK112=K110
                                  MapK117=K115





                                  share|improve this answer































                                    0
















                                    If you need to remap a key for a specific program only, I've just added this feature to hax11.




                                    I'd like to change PgUp to Home or PgDown to End.




                                    To do this with hax11, open the program's profile configuration file under ~/.config/hax11/profiles (e.g. ~/.config/hax11/profiles/usrlibfirefoxfirefox), and add:



                                    Enable=1
                                    MapK112=K110
                                    MapK117=K115





                                    share|improve this answer





























                                      0














                                      0










                                      0









                                      If you need to remap a key for a specific program only, I've just added this feature to hax11.




                                      I'd like to change PgUp to Home or PgDown to End.




                                      To do this with hax11, open the program's profile configuration file under ~/.config/hax11/profiles (e.g. ~/.config/hax11/profiles/usrlibfirefoxfirefox), and add:



                                      Enable=1
                                      MapK112=K110
                                      MapK117=K115





                                      share|improve this answer















                                      If you need to remap a key for a specific program only, I've just added this feature to hax11.




                                      I'd like to change PgUp to Home or PgDown to End.




                                      To do this with hax11, open the program's profile configuration file under ~/.config/hax11/profiles (e.g. ~/.config/hax11/profiles/usrlibfirefoxfirefox), and add:



                                      Enable=1
                                      MapK112=K110
                                      MapK117=K115






                                      share|improve this answer














                                      share|improve this answer



                                      share|improve this answer








                                      edited Apr 15 at 10:55

























                                      answered Apr 15 at 10:33









                                      Vladimir PanteleevVladimir Panteleev

                                      4711 gold badge6 silver badges15 bronze badges




                                      4711 gold badge6 silver badges15 bronze badges


















                                          protected by Seth Mar 10 '14 at 21:07



                                          Thank you for your interest in this question.
                                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                          Would you like to answer one of these unanswered questions instead?



                                          Popular posts from this blog

                                          Tamil (spriik) Luke uk diar | Nawigatjuun

                                          Align equal signs while including text over equalitiesAMS align: left aligned text/math plus multicolumn alignmentMultiple alignmentsAligning equations in multiple placesNumbering and aligning an equation with multiple columnsHow to align one equation with another multline equationUsing \ in environments inside the begintabularxNumber equations and preserving alignment of equal signsHow can I align equations to the left and to the right?Double equation alignment problem within align enviromentAligned within align: Why are they right-aligned?

                                          Training a classifier when some of the features are unknownWhy does Gradient Boosting regression predict negative values when there are no negative y-values in my training set?How to improve an existing (trained) classifier?What is effect when I set up some self defined predisctor variables?Why Matlab neural network classification returns decimal values on prediction dataset?Fitting and transforming text data in training, testing, and validation setsHow to quantify the performance of the classifier (multi-class SVM) using the test data?How do I control for some patients providing multiple samples in my training data?Training and Test setTraining a convolutional neural network for image denoising in MatlabShouldn't an autoencoder with #(neurons in hidden layer) = #(neurons in input layer) be “perfect”?