GetKeyState Method (Shell Object)

Retrieves the status of the specified virtual key.


nStatus = shell.GetKeyState( nVirtKey );


nStatus = shell.GetKeyState( nVirtKey )



A virtual key. If the desired virtual key is a letter or digit (A through Z, a through z, or 0 through 9), nVirtKey must be set to the ASCII value of that character. For other keys, it must be a virtual-key code.



nStatus = shell.GetKeyState( 0x11 );  // CTRL key
if( nStatus < 0 ) {
   alert( "the CTRL key is pressed" );


nStatus = shell.GetKeyState( &H11 )  // CTRL key
If nStatus < 0 Then
   alert "the CTRL key is pressed"
End If

Return Value

A negative value if the key is down. If the low-order bit is 1, the key is toggled (such as the CAPS LOCK key).


Supported on EmEditor Professional Version 24.2 or later.