Is there a way to detect the situation where a user is holding down the space key when they're on a command button? What I'm trying to do is create the equivalent of an auto-repeat command button whose Click method gets repeatedly called if the button has been held down for specific interval of time.
Specifically, I would like to detect these situations so I can:
a) Provide a visual alert to the user that they are holding down a button
b) Perform the click event, pause, and if the user is still holding down the button perform another click event and then go into a loop, performing click events (with optional short pauses between click events) until the user releases their space key.
I can do this for 'mouse click and holds' by trapping the mouse down event. I don't see an equivalent way to trap a 'space keydown' event in a command button.
I've investigated the inkey() and chrsaw() functions without much success. I'm thinking that one technique may be to activate a timer in the button's GotFocus event and use a Windows API call (which one???) to check if the space key is being held down and if so, generate the click events this way??? Thinking outloud, I would disable the timer on a True mouse click event, KeyPress event (meaning the space key is no longer being held down), and the LostFocus event.
Do I need to construct a 'custom' button in order to do this or does the standard button class provide me with the tools necessary to accomplish what I want to accomplish?
Any feedback on the concept of an auto-repeat button and/or its implementation would be appreciated.
Thanks!
Malcolm