Wednesday, March 24, 2010

Re: How find the hex code of composed key

On 24/03/10 20:36, epanda wrote:
> Hi,
>
>
> Christian recently show me that \x0c was the hex code of ctrl-l
>
> How can I compute the code of those sorts of keys'combination as ctrl-
> i etc....
>
> Thank you
>

You already got several answers about how to find it by experiment. Now
here is the rule, for Ctrl and/or Alt and a printable ASCII key. (I
regard Shift + <key> as a different key, to which the following also
applies.)

- Ctrl + ? = 0x7F (DEL)
- If 0x40 <= <key> <= 0x5F, then
Ctrl + <key> = <key> - 0x40
- If "a" <= <key> <= "z", then
Ctrl + <key> = Ctrl + Shift + <key> = <key> - 0x60
- If 0 <= <key> <= 0x7F (where <key> may include a Ctrl modifier) then
Alt + <key> = <key> + 0x80

Note that Alt is case-sensitive (Alt-A is not the same as Alt-a) but
Ctrl isn't (Ctrl-A = Ctrl-a = 0x01).

For printable keys other than 0x40 to 0x5F, a to z, and ?, Ctrl + <key>
is unspecified (may give different results, or nothing, from OS to OS).

For printable keys other than 0x00 to 0x7F, Alt + <key> is unspecified.

On some systems, Alt + <key> gives <Esc> followed by <key> instead. When
Vim can identify that the Esc is actually an Alt modifier, it stores it
as above, by setting the high bit. (See also :help 'timeout', :help
'ttimeout', :help 'timeoutlen', :help 'ttimeoutlen', :help :map-alt-keys)

The above says nothing about what a modifier does to a non-printable
key. The results vary from OS to OS and, within a single OS, from one
terminal to another (with a different termcap entry).

The above explains the following synonym pairs:
Ctrl-I and Tab (0x09)
Ctrl-M and Enter (0x0D)
Ctrl-[ and Esc (0x1B)
and also quite a lot of pairs between Alt-something and accented Latin1.


Best regards,
Tony.
--
Worst Vegetable of the Year:
The brussels sprout. This is also the worst vegetable of next
year.
-- Steve Rubenstein

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

To unsubscribe from this group, send email to vim_use+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.

No comments: