Squirrel/Client/Functions/Controls/GetKeyStatus
From Liberty Unleashed Wiki
(Difference between revisions)
(New page: {{Squirrel/Title|GetKeyState}} This function returns whether the key has been pressed down. This is useful for example if you want to bind key combinations. == Syntax == <code>bool GetK...) |
Latest revision as of 18:43, 8 April 2010
This function returns whether the key has been pressed down. This is useful for example if you want to bind key combinations.
[edit] Syntax
bool GetKeyStatus( int key )
[edit] Arguments
- key - This is the key you want to retrieve the status for. For keys 'A'-'Z' and '0'-'9' this value will be the ascii code of the character. For special keys, check a list here
[edit] Example
This example will print "Testage!" to the chatbox when the player presses CTRL + A key combination.
function onScriptLoad() { BindKey( 'A', BINDTYPE_DOWN, Testage ); } function Testage() { if ( GetKeyStatus( KEY_CONTROL ) ) Message( "Testage!" ); }
[edit] Notes
The function Message and call onScriptLoad were used in in this example. More info about them in the corresponding pages.