Key name synonyms

Discuss the future of the AutoHotkey language
lexikos
Posts: 7165
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:
Escape/Esc
Backspace/BS
Enter/Return
Delete/Del
Insert/Ins
Pause/Break (but CtrlBreak is a separate VK)
LControl/LCtrl
RControl/RCtrl
Control/Ctrl

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.

Spoiler
User avatar
jeeswg
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
User avatar
RaptorX
Posts: 71
Joined: 06 Dec 2014, 14:27
Facebook: e2c52f
GitHub: RaptorX
Contact:

Re: Key name synonyms

01 Nov 2020, 07:56

Totally agree, I think simplicity is better in most cases, and having double names while sometimes convenient cause a lot of confusion in other situations.
Curdflappers
Posts: 4
Joined: 13 Nov 2020, 03:18
GitHub: markwiemer

Re: Key name synonyms

14 Nov 2020, 04:31

I agree with @jeeswg on all accounts, switching to these names would:

- be simpler
- be consistent
- remove confusion with keywords (e.g. return, break)
Larkal
Posts: 14
Joined: 08 Mar 2019, 00:36

Re: Key name synonyms

06 Dec 2020, 16:22

Curdflappers wrote: I agree with @jeeswg on all accounts, switching to these names would:

- be simpler
- be consistent
- remove confusion with keywords (e.g. return, break)
Same, 100% agree.

Return to “AutoHotkey v2 Development”

Who is online

Users browsing this forum: No registered users and 2 guests