Difference between revisions of "Keys::isDown"

From RAGE Multiplayer Wiki
Jump to navigation Jump to search
Line 2: Line 2:
===Required Arguments===
===Required Arguments===
* keyCode {{RageType|Number}} [https://keycode.info code of the key].
* '''keyCode''' {{RageType|Number}} - [https://keycode.info code of the key].
===Return Value===
===Return Value===

Revision as of 15:51, 14 May 2019

Function to check if specific key is pressed down.



Required Arguments

Return Value

  • Boolean - true if the key specified is pressed, Otherwise false.


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

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