Keybindings for Alt+key don't seem to work - ideas?

41 views
Skip to first unread message

Roman Mitnitski

unread,
Jul 26, 2024, 9:36:10 PM7/26/24
to chromium-hterm

I'm a long-time mac user finally making the jump to chromebook.

One thing that holds me off is the copy-paste (and some other) shortcuts which use CTRL on chromebooks.

So I came up with the brilliant idea to swap ctrl and alt on the keyboard  - which works wonderfully with one exception - SSH.

There, I really need CTRL-C, CTRL-Z (and some others) to still use CTRL, but the key that used to be CTRL is now ALT.

  So, I figured, I will use hterm key bindings to map ALT-Z to CTRL-Z - and this where I got stuck. No matter how I try, the mapping does not  take effect.

 For example, I currently have the following mapping:

{
  "Alt+Z": "'HELLO1",
  "Alt+z": "'HELLO2",
  "Shift+PGDN": "scrollPageDown",
  "Shift+PGUP": "scrollPageUp"
}

 And well, when I press Alt-Z basically nothing happens. I would expect to see "HELLO1" or HELLO2 inputted into the command line, but all I see is cursor doing the visual bell (at least I think that is what it is, it turns white briefly and then goes back to red).

 Any ideas how to solve this (remap Alt+<key> to Ctrl+<key>) are welcome

Thanks


Chris Gerber

unread,
Jul 29, 2024, 1:10:49 PM7/29/24
to chromium-hterm, mit...@google.com
I just did a quick test on my machine, and both of the following keybindings are working for me:
```
{
  "Ctrl+A": "'hi'",
  "Alt+z": "'\u001a'"
}
```
It seems that maybe if you want to send a string, it needs to be in single-quotes, in addition to being in double-quotes. The second example sends the unicode character for Ctrl+z, to meet your actual stated goal. I was following the examples here: https://chromium.googlesource.com/apps/libapps/+/master/hterm/doc/KeyboardBindings.md#user-preference-keybindings-examples

Roman Mitnitski (mitnits@google.com)

unread,
Jul 30, 2024, 8:22:43 AM7/30/24
to Chris Gerber, chromium-hterm
Thank you, this indeed seems to work!

Generated a "full" ctrl+letter binding, and ended up discovering that it works.... almost.

The only keys I can definitely say are not working are Alt-C and Alt-V... Almost as if there was something doing copy-paste that gets in the way.

For the record, the binding I've made looks like this:
{
  "Alt+a": "'\u0001'",
  "Alt+b": "'\u0002'",
  "Alt+c": "'\u0003'",
  "Alt+d": "'\u0004'",
  "Alt+e": "'\u0005'",
  "Alt+f": "'\u0006'",
  "Alt+g": "'\u0007'",
  "Alt+h": "'\b'",
  "Alt+i": "'\t'",
  "Alt+j": "'\n'",
  "Alt+k": "'\u000b'",
  "Alt+l": "'\f'",
  "Alt+m": "'\r'",
  "Alt+n": "'\u000e'",
  "Alt+o": "'\u000f'",
  "Alt+p": "'\u0010'",
  "Alt+q": "'\u0011'",
  "Alt+r": "'\u0012'",
  "Alt+s": "'\u0013'",
  "Alt+t": "'\u0014'",
  "Alt+u": "'\u0015'",
  "Alt+v": "'\u0016'",
  "Alt+w": "'\u0017'",
  "Alt+x": "'\u0018'",
  "Alt+y": "'\u0019'",
  "Alt+z": "'\u001a'"
}

Reply all
Reply to author
Forward
0 new messages