Skip to content

System wide key remapping in Ubuntu

On my hp Spectre x360, the Ins key is only reachable via the Fn key as in Fn+PrtScr.

So I wanted to swap both keys. System-wide - so not only in X (using xev).

I finally found this which suggested the following procedure:

  1. Dump the current keyboard layout:

    sudo dumpkeys > backup.kmap
    
  2. Check the keycodes you want to change (Ins = 110, PrtScr = 99):

    sudo showkey
    

    (When you're done, wait 10 seconds for it to exit automatically.)

  3. Copy the dumped keyboard layout:

    cp backup.kmap ins-prt-swap.kmap
    
  4. Edit it to swap all occurrences of 99 to 110 and vice versa, e.g. change:

    keycode  99 = ...
    ...
    keycode 110 = Insert.....
    

    to

    keycode 110 = ...
    ...
    keycode  99 = Insert.....
    
  5. The suggested sudo setcon --save didn't work for me, but Ubuntu loads the active keymap from the file /etc/console-setup/cached.kmap.gz. So I gzipped my ins-prt-swap.kmap and copied the resulting ins-prt-swap.kmap.gz to /etc/console-setup/cached.kmap.gz.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

No comments

Add Comment

Markdown format allowed
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Form options