How to Remap a Foot Pedal With AutoHotkey

Four-Key Foot Pedal is a wide metal plate with four ribbed pedals in a row and a USB lead. AutoHotkey v2 can intercept its keyboard-like outputs on Windows and give them controlled, application-specific meanings.

How do you discover the pedal's keycodes?

Run a minimal AutoHotkey script that installs the keyboard hook, open its main window and inspect Key History after pressing each pedal. The history view shows virtual-key and scan-code information when Windows and the hook can see the event. Record press, release and repeat behavior for all four positions.

Test the same characters on the normal keyboard. If both devices produce the same event, a basic hotkey cannot infer which physical device sent it. Do not suppress a common letter until you understand that collision.

How do you intercept and rewrite an event?

Define one AutoHotkey v2 hotkey using the discovered key name or scan-code notation and make it send a harmless destination such as Escape. Add the wildcard or pass-through prefixes only when their documented behavior is required. A prefix can change whether the original event reaches the active application.

Keep a tray-menu or keyboard route for exiting the script. Test down and up transitions, especially for push-to-talk, because a missing release can leave an action stuck. Then add the other pedals one at a time.

How can bindings change by application?

Use #HotIf with a WinActive expression to make the following hotkeys context-sensitive. Match a stable executable or window class rather than a document title that changes. End or replace the condition deliberately before defining global bindings later in the file.

Focus can change while a foot is moving, so prefer short named shortcuts over text macros. Test the rule with the target app, terminal, browser and desktop focused. A pedal intended for mute should not type or submit anything elsewhere.

What if two devices send the same key?

A normal AutoHotkey keyboard hotkey works from the logical event and does not provide a simple per-keyboard filter. The cleanest solution is to configure the pedal itself to emit unused keys, if its supported configuration allows that. Otherwise use a device-aware input layer and let AutoHotkey react to distinct outputs.

The Four-Key Foot Pedal offers four physical positions, but it does not justify four risky macros. Start with push-to-talk, Escape and two reversible navigation controls. Store no passwords or secrets in the script, and repeat the Key History check after changing USB ports or pedal configuration. Comment every scan code with its physical pedal position. That note becomes essential when a later hardware setting changes what one pedal emits.

Back to blog