1. Home
  2. Windows Tips
  3. Change keyboard shortcut in an autohotkey script

How to change the keyboard shortcut in an AutoHotKey script

Any time you need to do something on your system with a keyboard shortcut, AutoHotKey is often the go to solution. That’s not to say AutoHotKey can do everything with just a few keystrokes. You do have to write a script and the app has its limitations but for what it can do, it works great. If you know how to write an AutoHotKey script, then setting a keyboard shortcut for it isn’t a problem. If you’re unfamiliar with writing these scripts and need to change the keyboard shortcut in an AutoHotKey script, it’s pretty easy to do.

Check out this script for managing brightness levels.

Keyboard shortcut in AHK script

The keyboard shortcut in an AHK script is declared at the very start. The line looks like this;

Space & t::

The bit before the two colons is the keyboard shortcut. The above shortcut uses the space bar and the ‘t’ key however it’s separated by the & key. This isn’t how all keyboard shortcuts are written though but all shortcuts end with the two colons.

Space bar

To use only the space bar as a keyboard shortcut, you have to enter;

Space

To use it in combination with a letter key, you need to enter;

Space & [letter]

Example

Space & t

Tab, Escape, Backspace, and Enter

For these four keys, the same rule as the space bar applies. To declare any of the four keys as a shortcut or part of a shortcut, simply enter its name;

Tab key: Tab

Escape key: Escape

Backspace key: Backspace

Enter key: Enter

To combine these keys with another key, use & to separate it.

Examples

Tab & t

Escape & e

Backspace & b

Enter & e

Ctrl key

There are two ways to use the Ctrl key. You can enter Control or you can use the symbol: ^. When you use Control to declare the shortcut, the syntax is a bit different for combining it with other keys.

Examples

Control & t

^t

If you want to differentiate between left and right control keys, you can use the following;

Left Control key: <^

Right Control key:^>

Alt key

To use the Alt key, you can use either Alt or !. The examples below will illustrate how to combine it with other keys.

Examples

Alt & t

!t

Shift key

The Shift key can be used in a shortcut by declaring it as Shift or using the + symbol. For the left shift key, use <+ and for the right shift key, use +>.

Examples

Shift & t

+t

You should know that AutoHotKey has extensive documentation available for shortcuts. Symbols for just about every key have been explained although the documentation lacks in examples.

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.