• getKey ?-p str? ?-a? ?-b? ?-c? ?-d? ?-k? ?-m?
Capture a key combo. The command prompts the user to enter a key combo, i-e
to press a key on the keyboard, with or without modifier keys. The command
returns the keydown event in various forms depending on the chosen options.
This command returns a list which may contain the modifiers, the
character code and the key code (in that order). You specify which elements
you want using any of the following options:
If none of these options is specified, -c is assumed.
- -m to include the modifiers;
- -c to include the character code;
- -k to include the key code;
You may additionally specify a format with the following options:
The -p option specifies a prompt string to
display in the status bar. If it is not specified, the command displays a
default string asking to enter a key combo.
- -a to return the ascii code of the
character (rather than the character itself). This option is ignored if
the -c option is missing.
- -d to return the modifiers as a decimal
value which has the same meaning as with the [getModifiers] command (see the table of modifier flags). Otherwise the modifiers are returned as a
string containing the letters c, o, s, z (see the documentation
of the [binding] command for the meaning of these
letters). This option is ignored if the -m option is missing.
The -b option returns the key combo in a
format suitable for use with the [binding] command. By
default, it assumes the -c option, but specifying the -k
option is possible in order to get a virtual key binding.
Here are some examples of the output of the command in the case of a
⌘A combo (note that the ascii code of 'a' is 97 and
that the corresponding key on the keyboard has code 12):
getKey -m -c
getKey -m -c -d
getKey -m -c -a -d
getKey -m -c -k
|c a 12|
getKey -b -k