Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Detecting when a key is being held down in realtime
Message
 
To
11/01/2002 01:24:46
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00603357
Message ID:
00603421
Views:
18
This message has been marked as the solution to the initial question of the thread.
Malcolm,

Have you checked out the GetKeyState Windows API? I've used it for Shift and Ctrl but the MSDN help says you can check of character keys as well.

>Is there a Windows API function to determine if a user is holding down a particular key?
>
>I want to be able to poll for a specific key down status in realtime (while a user is still holding down a specific key) vs. being dependent on the KeyPress event which reads an easily flooded keyboard typeahead buffer.
>
>In other words, I would like to stop a specific action as soon as a user removes their finger from the key they are holding down vs. waiting for the user's keyboard buffer to empty (which could be many seconds after they have stopped holding down a specific key)
>
>I've tried various settings of typeahead (as well as clearing the typeahead buffer). I've also tried 'eating' keystrokes via the following ...
>
>
>* example: eat all space keystrokes in keyboard buffer
>do while inkey() == 32
>enddo
>
>
>The inkey() technique above results in a very 'jittery' feel. I use a similar technique in a command button's mousedown() event to trigger multiple click() events while a user presses on a command button and this behaviour is very smooth. I'm hoping I can emulate the same smooth behavior via an equivalent of a (polled?) KeyDown event.
>
>Thanks!
Caroline
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform