1. Detecting if the shift, control or alt keys are depressed with
- Posted by andy at systemzone.freeserve.co.uk Sep 24, 2003
- 394 views
Hello Euphorians, I want to code up a function to report if the shift, control or alt keys are currently depressed by the user. I'm guessing I need to access a function (or two) within a standard windows supplied DLL. Any clues on where to start greatly appreciated. Regards, Andy Cranston.
2. Re: Detecting if the shift, control or alt keys are depressed with
- Posted by Derek Parnell <ddparnell at bigpond.com> Sep 25, 2003
- 375 views
----- Original Message ----- From: <andy at systemzone.freeserve.co.uk> To: "EUforum" <EUforum at topica.com> Subject: Detecting if the shift, control or alt keys are depressed with exw.exe > > > Hello Euphorians, > > I want to code up a function to report if the shift, control or alt keys > are currently depressed by the user. I'm guessing I need to access a > function (or two) within a standard windows supplied DLL. > > Any clues on where to start greatly appreciated. > If using win32lib, just call getKeyState() like this ... if getKeyState(VK_SHIFT) then -- shift key is pressed ... elsif getKeyState(VK_CONTROL) then -- Control key elsif getKeyState(VK_MENU) then -- Alt key end if If using API directly... constant dllUser32 = open_dll("user32.dll") apiGetKeyState = define_c_func(dllUser2, "GetKeyState", {C_UINT}, C_UNIT) global function getKeyState( atom key ) -- return the state Shift, Control, or Menu keys return (floor( c_func( apiGetKeyState, {key} ) / 2 ) != 0) end function -- Derek