How to Remap a Macropad With AutoHotkey
KM16 Macropad has sixteen keycaps, an anodised aluminium body, one large knob and two smaller knobs. VIA can give its controls uncommon outputs, while AutoHotkey v2 can interpret those outputs on Windows.
Why should the pad emit spare keys first?
AutoHotkey normally sees a key event, not the physical keyboard that produced it. If the pad sends the same letter as the main keyboard, a plain remap can affect both. Configure the pad in VIA to emit a spare function key or uncommon combination, verify that output, and use it as the AutoHotkey trigger.
This two-layer design is easier to reason about. The firmware identifies the physical position by its unusual output, and the Windows script decides what that output does. Record both layers before adding application-specific behavior.
What does a basic AutoHotkey v2 remap look like?
AutoHotkey documents direct remapping with the form OriginKey::DestinationKey. For example, a spare function-key output can become a familiar editor key. Use the v2 syntax from the current documentation rather than copying an old script, because many examples online were written for a previous major version.
Start with a harmless destination such as Escape. Reload the script, test the pad, then check that the main keyboard still behaves normally. Add one trigger per test cycle and keep a quick way to exit the script if an input repeats unexpectedly.
How do you restrict a key to one application?
Use AutoHotkey's #HotIf directive with a window condition for context-sensitive hotkeys. A pad input can then mean one thing in an editor and remain unused elsewhere. Window titles can change, so prefer stable executable or class information and verify it with the tools supplied by AutoHotkey.
Focus is still part of the result. A rule that sends text or ordinary keystrokes acts on the active target. Test it with the intended editor, a terminal and a browser focused. If a mistake would submit data or alter files, use the application's named shortcut instead of simulated typing.
Should a key type an entire prompt?
Usually not. AutoHotkey's SendText sends literal text to the focused window, and long content can still land in the wrong field or be affected by application behavior. A short template opener is defensible when it does not submit automatically, but complete prompts are easier to review as snippets inside the application.
The KM16 Macropad can hold many bindings, yet a small context-aware set is safer. Keep the source script readable, avoid storing secrets in it and revisit each rule when the target application changes its shortcuts.