3

I am on Ubuntu Snap server with no GUI and would like to remap my caps-lock to escape for my terminal sessions. I have tried modifying the /etc/defaults/keyboard to include caps:escape but there’s no change to the caps lock function.

Maybe some other things to note: I am trying to do this from an iPad Pro using Apple’s “Folio Keyboard”. IOS gives no option to remap but I was hoping that there was a way on the server.

Thanks

austinbv
  • 1,923
  • Ok,could you just quickly tell us what you mean by would like to remap my caps-lock to escape for my terminal sessions

    Do you want to have ESC and CAPS switch their functions?

    Do you want the new modified-CAPS and ESC to essentially both remain operational and produce the same outcome as would have been produced by ESC?

    Please provide us some more info, because writing the final script will be a breeze and will provide it promptly. but I cannot start writing one until I understand what your requirements are.

    – NetIceGear Mar 05 '19 at 02:20
  • I am looking to have the capslock key function as esc – austinbv Mar 05 '19 at 04:02
  • Have you tried the suggestions in these answers? – anonymous2 Mar 05 '19 at 14:33
  • Does CMD+[ work for Escape key as answer below recommends trying? – WinEunuuchs2Unix Mar 11 '19 at 09:44

2 Answers2

0

It's not completely clear if you are on a client or on the server so let me try to distinguish.

If you ssh from another machine then input from keystrokes are handled by your SSH terminal application on the client machine, not by anything on the server.

So would be enough to change the keymap on client side like i.e. here.

If Ipad does not allow it I'm afraid you should use another remote terminal or relay on the application you use to remap the keys (if possible). here a quick how-to for vim, emacs has something similar.

For the rest of the answer I'll assume you are logged "on Ubuntu Snap server" not remotely.

There are 2 ways to achieve the same:

  1. through loadkeys (requires console-data to be installed)

dump the layout of your keyboard:

    # dumpkeys >modified.kmap

Modify the layout as needed:

    # in your case you should substitute in the modified.kmap
    #a not elegant way would be to add at the end of the file: 
    keycode 1 = Caps_Lock
    keycode 58 = Escape

Apply changes

    # loadkeys ./modified.kmap 

Check changes are in place:

    # dumpkeys |grep "Escape"
    [...]
    keycode  58 = Escape          
    # dumpkeys |grep "Caps_Lock"
    keycode   1 = Caps_Lock    
  1. through a trick with /etc/default/keyboard

Add the following to your layout in /etc/default/keyboard

   XKBOPTIONS="caps:swapescape"

Reconfigure the keyboard through dpkg NB keeping the options (this has to be done also in case your layout is already the correct one)

   # dpkg-reconfigure keyboard-configuration

answer yes when you are asked Keep current keyboard options in the configuration file?

Let me know if this was useful.

0

The Apple Folio Keyboard doesn't have an Escape key in the first place.

Google searches reveal to imitate Escape one uses CTL+[, FN+[ or CMD+[, depending on the smart keyboard manufacturer for your iPad.

Your first step is to determine which key combination works as the Escape key (ASCII 27, Unicode U+001B, or Ctrl + [) and then map your CAPS lock key to that combination.