Hex codes for input key combinations

6,688

Solution 1

It's not a matter of looking up those keycodes, because in its default configuration iTerm2 doesn't do anything special for the keys. For instance, if you do

cat -v

and press controlV ("literal next") before pressing each of those controlalt+character combinations, you're likely to find (as I did) that the result is just as if it ignored the alt modifier. The rather long answer in Sending Control+Alt+ <char> to terminal in iTerm2 seems to have concluded something based on this default behavior which is not helpful.

On the other hand, you can define a key binding, using hexadecimal values for the (ASCII) characters that you would like to send. In this screenshot, I have highlighted a binding that I added for controlaltf (lowercase F), which is 0x66:

example of send-hex-codes

The iIterm2 documentation is brief:

Send Hex Code

This action allows you to enter a sequence of hex codes that will be sent. Each value should begin with "0x" followed by one or two hex digits (0-9, a-f, or A-F). Each code should be separated by a space. You can see a list of hex codes on http://asciitable.com/ in the "Hx" column.

but the screenshot here may help you understand what's needed.

Solution 2

I had a challenge to setup home and end. These are what I did.

Forward word - escape sequence f

Backward word - escape sequence b

Home - Hex code 1

End - Hex code 5

enter image description here

Share:
6,688

Related videos on Youtube

Amelio Vazquez-Reina
Author by

Amelio Vazquez-Reina

I'm passionate about people, technology and research. Some of my favorite quotes: "Far better an approximate answer to the right question than an exact answer to the wrong question" -- J. Tukey, 1962. "Your title makes you a manager, your people make you a leader" -- Donna Dubinsky, quoted in "Trillion Dollar Coach", 2019.

Updated on September 18, 2022

Comments

  • Amelio Vazquez-Reina
    Amelio Vazquez-Reina over 1 year

    In iTerm2 one can setup keyboard shortcuts so that for a given input sequence, iTerm2 sends a specific hex code to the terminal.

    What exactly are these hex codes? And how can I identify a hex code for a given input key sequence?

    In my case I am specifically interested in looking up the hex code associated with Control + Alt + <char> with char being u,i,j,k and l.

    I found this article that shows some examples of these conversions, but it doesn't list any Control + Alt + <char> combinations.

    The hope is that ultimately this will help me solve this other question in AskDifferent.