-
Notifications
You must be signed in to change notification settings - Fork 232
Special Keys
AutoKey offers several API-supported special keys for use in your phrases or scripts and you can also customize some of your own.
The below table lists all the names used for special keys.
| Keys | String |
|---|---|
| ALT | <alt> |
| ALT_GR | <alt_gr> |
| BACKSPACE | <backspace> |
| CAPSLOCK | <capslock> |
| CONTROL | <ctrl> |
| DELETE | <delete> |
| DOWN | <down> |
| END | <end> |
| ENTER/RETURN | <enter> |
| ESCAPE | <escape> |
| F1-F35 * | <f1>-<f35> |
| HOME | <home> |
| INSERT | <insert> |
| LEFT | <left> |
| MENU | <menu> |
| NP_ADD | <np_add> |
| NP_BEGIN | <np_5> |
| NP_DELETE | <np_delete> |
| NP_DIVIDE | <np_divide> |
| NP_DOWN | <np_down> |
| NP_END | <np_end> |
| NP_HOME | <np_home> |
| NP_INSERT | <np_insert> |
| NP_LEFT | <np_left> |
| NP_MULTIPLY | <np_multiply> |
| NP_PAGE_DOWN | <np_page_down> |
| NP_PAGE_UP | <np_page_up> |
| NP_RIGHT | <np_right> |
| NP_SUBTRACT | <np_subtract> |
| NP_UP | <np_up> |
| NUMLOCK | <numlock> |
| PAGE_DOWN | <page_down> |
| PAGE_UP | <page_up> |
| PAUSE | <pause> |
| PRINT_SCREEN | <print_screen> |
| RETURN/ENTER | <enter> |
| RIGHT | <right> |
| SCROLL_LOCK | <scroll_lock> |
| SHIFT | <shift> |
| SPACE * | (space character) |
| SUPER | <super> |
| TAB | <tab> |
| UP | <up> |
- F1-F35: The <F13>-<F35> keys were present on some keyboards in the 80s. Although those are no longer present on modern keyboards, X11 still supports these keys. You can assign them as hotkeys in applications and use them from within AutoKey to trigger the assigned actions. Application support for the upper Function keys varies, as some GUI toolkits may not support them.
- SPACE: AutoKey doesn't have a name for the space-bar. The (space character) entry in the String column is a suggestion rather than a name and it lets you know that an actual space should be used in API calls.
Keys that aren't listed in the AutoKey API can still be pressed and released as long as you know their X keycodes. In Linux, you can run the xev command in a terminal window and then press a key to see its data. There will be a lot of output that will be duplicated each time you press and release a key, because the xev command reacts to a key press and a key release as separate events. What you'll be looking for is the number after keycode in the output.
To display all output from any input device:
xevTo display all output from only the keyboard:
xev -event keyboardTo display the word "keycode" followed by the keycode:
xev -event keyboard | grep -Eo ".{,0}keycode.{,4}"To display only the keycode:
xev -event keyboard | grep -Po '(?<=keycode\s)[^\s]*'A key's keycode can be used in a custom code string. For example, the left Shift key's keycode is 50, so it uses the <code50> string, whereas the right Shift key's keycode is 62, so it uses the <code62> string.
A key's ASCII code may also be useful at times. The showkey -a command in a terminal window displays the ASCII code (decimal value), octal value, and sequence representation of each key that you press until you press the Ctrl+D to exit out of it.
There are several ways to add special keys to your phrases or scripts:
-
To use special keys in a phrase, insert their strings anywhere.
-
To use a special keys in a script, use their strings with any of AutoKey's several Keyboard API calls. Some examples:
- The press_key and release_key API calls can be used to press and release one key (the right Shift key in this example):
keyboard.press_key("<code62>") keyboard.release_key("<code62>")
- The send_key call can be used to press and release one key (the right Shift key in this example):
keyboard.send_key("<code62>")
- The send_keys call can be used to press and release more than one key:
- To press and release two keys at the same time (the Ctrl and Escape keys in this example), insert a plus sign between their strings:
keyboard.send_keys("<ctrl>+<escape>")
- To press and release two (or more) keys, one after another (the Ctrl and Escape keys in this example), include their strings without anything between them:
keyboard.send_keys("<ctrl><escape>")
- To press and release two keys at the same time (the Ctrl and Escape keys in this example), insert a plus sign between their strings:
- The press_key and release_key API calls can be used to press and release one key (the right Shift key in this example):
- For more information on key combinations, see the Key Combinations page.
- For more information on the keyboard API calls, see the Keyboard section of the API wiki page.
- For more information on the NP_BEGIN key, see this StackOverflow page.
-
Home
- About
- Beginners' Guide
- Documentation
- FAQ
- Administration
- Community
- Development
- Features
- Development Testing