Key name synonyms

Discuss the future of the AutoHotkey language
Posts: 6855
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Key name synonyms

26 Oct 2019, 20:02

Currently there are some keys that have multiple names, with no difference in VK or SC:
Pause/Break (but CtrlBreak is a separate VK)

It seems preferable to remove Return and Break due to the ambiguity with control flow statements. (I might be biased, as I've always known them as Enter and Pause.)

Because hotkeys are identified by name, Del:: and Delete:: are two different hotkeys, and are not detected as duplicates. This sometimes causes issues with context-sensitive hotkeys; for example, Problems with key name synonyms (Ex: Delete and Del). On the other hand, it might be better to identify these hotkeys by key code instead - e.g. treat Backspace, BS and vk08 as the same. A side-effect would be that A_ThisHotkey would return whichever name was used first (it already "locks in" the exact string of modifier symbols).

Having multiple names also increases the risk of confusion for functions that return key names, such as GetKeyName, Input and InputHook.EndKey. For example, and end key can be passed as "Del" but return "Delete" (this is documented; also, vk2E does the same).

The longer names are sometimes better for clarity, but the shorter names are more convenient (e.g. for {BS 3}by the way). Hotstrings or auto-replace within the editor can compensate for loss of convenience if the shorter names are removed, but the shorter names are also generally better if the key name is included multiple times in a string.

FWIW, the Microsoft Style Guide includes a section about keys. They recommend "Backspace", "Ctrl", "Del", "Enter", "Esc" and "Insert". Sentence case is used for names with multiple words, but that doesn't matter since we don't use spaces.

User avatar
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Key name synonyms

27 Oct 2019, 07:45

If I had to pick one:
Escape/Esc [Esc]
Backspace/BS [Backspace][I haven't minded using the longer form with Send]
Enter/Return [Enter]
Delete/Del [Del][consistent with NumpadDel]
Insert/Ins [Ins][consistent with NumpadIns]
Pause/Break [Pause]
LControl/LCtrl [LCtrl]
RControl/RCtrl [RCtrl]
Control/Ctrl [Ctrl]
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 21 guests