Blog

Why Global Shortcuts Silently Stop Working on Windows, and the Fix

Written by InSnap · Published · global hotkey, keyboard shortcut, windows, troubleshooting, how it works

Why Global Shortcuts Silently Stop Working on Windows, and the Fix

A keyboard hook can be removed by Windows without any warning. How global shortcuts work, why they die quietly, and how InSnap keeps them alive with a backup and a fresh hook.

A global shortcut that works for days and then does nothing is not always a conflict with another program. Windows has a rule that lets it quietly remove a keyboard hook that was too slow, and the program that installed the hook is not told. This article explains how global shortcuts are built on Windows, why they can die silently, and what InSnap does about it.

Two ways to build a global shortcut

  • RegisterHotKey asks the system to send a message when a key combination is pressed. It is simple, but the first program to register a combination owns it, and a second one is refused.
  • A low-level keyboard hook sees every key press before the program you are typing into. It can react and also swallow the key. It is more powerful, but it carries the risk below.

InSnap uses a hook as its main path so that a shortcut it owns is not also delivered to the foreground app, and a registered hotkey as a backup.

The rule that kills hooks

Microsoft's documentation for the low-level keyboard callback says:

  • The hook runs in the thread that installed it, and that thread must have a message loop.
  • The callback must finish within the LowLevelHooksTimeout value stored in the registry under the current user's Control Panel\Desktop key, in milliseconds.
  • If it takes too long, the system passes the key to the next hook. On Windows 7 and later the hook is also silently removed, and there is no way for the application to know. On Windows 10 version 1709 and later the allowed time is capped at 1000 ms.
  • For this reason it recommends running hooks on a dedicated thread that passes work to another thread and returns immediately.

A program that does heavy work on the same thread, such as encoding a PNG, can miss the deadline once. After that, the shortcut is dead until the program restarts, and nothing is shown.

What InSnap does

1. A dedicated hook thread. The hook lives on its own thread with a message loop. Its callback does one thing: it looks the key up in a small table of shortcuts and, if there is a match, sends a single integer to the main thread. All the real work happens there, so a slow screenshot cannot make the hook late.

2. Swallow completely. When a shortcut matches, the key is swallowed. Holding the key down fires the action once, and the key-up is swallowed too, so the foreground app never sees an orphaned release. The modifier keys themselves are never swallowed.

3. A backup registration. Every combination is also registered with RegisterHotKey. While the hook works, it swallows the key first and the system never fires the backup. If the hook has been removed, the key reaches the system, the backup fires, and the action still runs.

4. Repair after a fallback. A backup firing means the hook missed a key. InSnap asks the hook thread to install a new hook, putting it at the front of the chain, with a cooldown of ten seconds. It also reinstalls the hook every five minutes in case another program has pushed it down the chain.

5. A calmer thread. The hook thread runs at a high priority and opts out of the power throttling that Windows applies to background processes, because a throttled thread answers late.

6. Modifier state is refreshed. Every two seconds the thread re-reads the physical state of the modifier keys. Elevated windows and the secure desktop can swallow key-up events, which would leave Ctrl or Alt looking pressed forever and make every combination fail to match.

Using a shortcut to pin the clipboard
The screenshot selection that a shortcut starts

When a shortcut still does nothing

  1. Is the foreground program running as administrator? A normal program's hook does not see keys typed into a higher-privilege window. The backup registration is not affected by that, but check the program first.
  2. Is it a game in exclusive full screen? Some games read the keyboard through raw input and may ignore hooks.
  3. Does another program swallow it earlier? If another hook sits earlier in the chain, your shortcut never reaches InSnap. Windows gives no way to detect that, so try a different combination in Settings › Hotkeys.
  4. Is the combination valid? Keys on the numeric pad are different keys from the number row.

Mac is different

macOS registers a shortcut with the system, and the system reports a conflict at registration time. There is no equivalent of a timed hook that disappears, so none of the repair logic above applies.

FAQ

Why did my shortcut stop working without any error?

If it relied on a keyboard hook, Windows may have removed that hook after a slow callback, and it does not notify the program. A restart restores it until the next time.

Is the InSnap shortcut still delivered to the app I am typing in?

No. When a combination matches, it is swallowed so the foreground app does not see it, which also means you should pick combinations that you do not need elsewhere.

Does a hook record what I type?

InSnap's hook only checks keys against its list of shortcuts and ignores the rest. Nothing is logged or sent anywhere.

How do I change a shortcut that conflicts with another program?

Open Settings › Hotkeys, click the field of the action and press the new combination. Pick one that other programs are not using.

Your next screenshot is one hotkey away.

macOS 14.4+ (Apple Silicon & Intel) · Windows 10+ (64-bit)