May 7th, 2018

After all, it’s called a hotkey, not a hotcharacter

A customer was writing a remote access program, and they were having trouble injecting hotkeys into the system.

We are sending the modified key as a scan code, and the base character as a Unicode character. We find that shortcuts of the form Modifier+Letter, such as Ctrl+A, are not working. Are there known limitations for keyboard shortcuts sent as a scancode+Unicode character?

We are sending the base character as a Unicode character to avoid issues with localization and keyboard layouts.

Keyboard shortcuts are based on virtual key codes, not Unicode characters. After all, it’s called a hotkey, not a hotcharacter.

Continuing the above example, the Ctrl+A hotkey is not a Ctrl plus the Unicode character U+0041 (LATIN CAPITAL LETTER A).

You cannot hold the Ctrl key while typing Alt+0 Alt+6 Alt+5 on the numeric keypad to get a Ctrl+A.

Even if CapsLock is off, you don’t have to hold the shift key to get a capital A.

For the hotkey Win+1, you have to press the 1 on the main keyboard, not on the numeric keypad, even if NumLock is on.

Keyboard hotkeys consist of the applicable modifiers, combined with the key on the keyboard that has the appropriate symbol printed on it. Sending a Unicode character isn’t the same as simulating a press of a key on a keyboard.

You have to send the virtual key to complete the hotkey sequence.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.