General Computing
windows-7 keyboard mouse key-binding joystick
Updated Sat, 02 Jul 2022 09:45:37 GMT

Simulating mouse (or joystick) movement with keyboard in Win 7

Pretty much what the "Mouse Keys" that can be enabled via the Ease of Access Centre do, only those are useless because they are extremely slow and have a delay at the start.

Some more info: There's a game I play that is similar to a flight simulator, but yaw and pitch are controlled by the mouse and there's no option in-game to remap this to keyboard buttons. So what I want is that if I press the 4 key on the numpad (or some other key, I don't care) then the game reacts as if I were moving the mouse to the left, with no delay or acceleration or whatever, just the way it works in normal flight sims where you use a keyboard by default.

I don't need the diagonal directions, just up/down and left/right would be enough. Since I won't be able to control the cursor speed I'll need some way to set a fixed speed that feels right in the game, preferably separately for each axis.

Edit: Since mapping some keys to joystick axes would also work I tried to find a program that does this, but no luck. It seems everyone needs to map joystick buttons to keys on the keyboard, but not the other way around. Surely this can't be that difficult?


The solution is called AutoHotkey and a beginner's tutorial can be found here.

This is my script:

SetTimer, Main, 1
if (GetKeyState("Up", "P"))
    MouseMove, 0, -25, 0, R
if (GetKeyState("Down", "P") or GetKeyState("NumpadClear", "P"))
    MouseMove, 0, 25, 0, R
if (GetKeyState("Right", "P"))
    MouseMove, 50, 0, 0, R
if (GetKeyState("Left", "P"))
    MouseMove, -50, 0, 0, R

NumpadClear is the middle numpad key, so this allows to use a WASD pattern on the numpad (8456).

External Links

External links referenced by this document: