Steve,
THANKS! Your new code works great under VFP 7!
Note: I added two lines to prevent the Space key from overflowing the keyboard buffer. This change makes the button more responsive to the real-time state of the spacebar, i.e. (almost) as soon as you release the space bar, the click events stop.
Thank you again for your help!
Malcolm
LPARAMETERS nKeyCode, nShiftAltCtrl
if nKeyCode = 32
do while inkey() == 32
enddo
nKeyCode = 13
nodefault
dodefault(nKeyCode, nShiftAltCtrl)
endif
>>Hi Steve,
>>
>>Thanks for your feedback! I tried your suggestion and it failed for 2 reasons:
>>
>>1. The KeyPress event on a command button isn't fired until the user releases the space key (after the 'KeyUp' event). If command buttons had a 'KeyDown' event then your idea would probably work.
>>
>>2. Strange, but true - under VFP 7 (didn't try VFP 6), your code prevents the command button from losing focus via the keyboard. I can change focus by using the mouse, but the tab and arrow keys will not exit me from the command button.
>>
>>Any other suggestions? What I think(?!) I'm looking for is a Windows API function to check for a KeyDown event (KeyPressed vs. KeyPress?). I guess I would have to set a timer to check the status of the Space key - if pressed, do the Click event.
>>
>>Malcolm
>>