Difference between revisions of "Keys::isDown"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
m (Altered wording)
Line 2: Line 2:
  
 
==Parameters==
 
==Parameters==
* '''keycode''' - code of the key (Number).
+
* '''[https://keycode.info keycode]''' - code of the key (Number).
  
 
==Example==
 
==Example==
Line 9: Line 9:
 
<syntaxhighlight lang="javascript">
 
<syntaxhighlight lang="javascript">
 
setInterval(() => {
 
setInterval(() => {
     if (mp.keys.isDown(112) === true) { // 112 is the key code for F2
+
     if (mp.keys.isDown(113) === true) { // 113 is the key code for F2
 
         mp.gui.chat.push('F2 key is pressed!');
 
         mp.gui.chat.push('F2 key is pressed!');
 
     } else {
 
     } else {

Revision as of 21:58, 13 May 2019

Returns true if the key specified 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(113) === true) { // 113 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