Re: Detecting if the shift, control or alt keys are depressed with

new topic     » goto parent     » topic index » view thread      » older message » newer message

----- 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

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu