How is keyboard auto-repeat implemented on a Windows PC?
Asked Answered
R

3

2

I want to be able to intercept (and do arbitrary processing on) auto-repeating key presses on Windows. I'd like to know how keyboard auto-repeat is implemented so that I know what options I have. i.e. can I intercept at the:

  • application,
  • device driver and/or
  • hardware level

?

Update: It looks like auto-repeat is (poorly?) generated at the hardware level and then overridden by device drivers (see here).

Relentless answered 18/5, 2009 at 9:23 Comment(0)
S
4

To modify or filter behavior, you can intercept keys using a hook:

SetWindowsHookEx using WH_KEYBOARD

The hook procedure receives, among others, the repeat count (due to holding down the key)

Note that the low level keyboard hook (WH_KEYBOARD_LL) does not receive the repeat count.

If all your windows are created in the same trhead, you can use a thread-specific hook, and avoid moving the hook procedure to a DLL.


I dimly remember that repeat counts are generated by the keyboard itself and the LL hook sends repeated keydown events - I may be mistaken, though. Under DOS, the key repeat rate and time that was set in BIOS or through a BIOS call did return to default values when a DIN or PS/2 keyboard was unplugged and replugged. I am not sure WHY you need to know exactly.

Scurrile answered 18/5, 2009 at 12:42 Comment(0)
V
0

I suggest that you might want to edit your question... your actual question is "How to suppress auto-repeat on Windows in ${yourLangauge}"...

To which my response is, I haven't got a clue, I've only ever done it in assembler (MASM 80286)... and even then I found a solution on a BBS (does anyone remember them) and just used it. From memory, the intercept has to be done at the device-driver level.

The implementation of autorepeat ($100 says it's assembler) problably won't shed any light on supressing it... that and Microsoft plays those cards very close to it's chest.

Cheers. Keith.

EDIT: I've just thought... techniques may now differ between versions of windows and the plethora of various devices... Oh goodie!

Virendra answered 18/5, 2009 at 9:40 Comment(1)
No, I really do want to know how it's implemented. The bit about suppression is for background info. My suspicion was that it might be at the hardware level (which, if true, gives me more options for interception).Relentless
E
0

Sounds likes this is "Not programming related", however. Go to "Accessibility Options" in control panel. Select "Settings" under "Filter Keys" group, in here, you can switch off repeating keys for that user on that machine.

Hope this is what your looking for.

P.S. Above instructions given for Windows XP.

Evadne answered 18/5, 2009 at 9:49 Comment(1)
I want to be able to suppress this programmatically but I'm happy that I'll be able to work out how to do this once I understand how/where auto-repeat is implemented.Relentless

© 2022 - 2024 — McMap. All rights reserved.