Difference between revisions of "Keys::isDown"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
(Add "See also" section)
Line 6: Line 6:
 
==Example==
 
==Example==
 
An interval that runs every half-second and outputs the state of the F2 key (pressed or not).
 
An interval that runs every half-second and outputs the state of the F2 key (pressed or not).
 
+
<div class="header" style="background-color: #AE4040; color: #FFFFFF; border: 2px solid #408DAE;">
 +
<div style="margin: 10px 10px 10px 10px;"><b>Client-Side</b></div>
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
 
setInterval(() => {
 
setInterval(() => {
Line 16: Line 17:
 
}, 500);
 
}, 500);
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
</div>
  
 
==See also==
 
==See also==
 
{{KeyBinding_function_c}}
 
{{KeyBinding_function_c}}

Revision as of 22:43, 4 April 2018

Returns true if the key specific is pressed. Otherwise, returns false.

Parameters

  • keycode - code of the key (Number).

Example

An interval that runs every half-second and outputs the state of the F2 key (pressed or not).

Client-Side
setInterval(() => {
    if (mp.keys.isDown(112) === true) { // 112 is the key code for F2
        mp.gui.chat.push('F2 key is pressed!');
    } else {
        mp.gui.chat.push('F2 key is not pressed!');
    }
}, 500);

See also