Keys::isUp: Difference between revisions

From RAGE Multiplayer Wiki
mNo edit summary
Line 8: Line 8:


===Return Value===
===Return Value===
* {{RageType|Boolean}} - <code>true</code> if the key specified is released, Otherwise <code>false</code>.
* {{RageType|Boolean}} - <code>true</code> if the key specified is released, otherwise <code>false</code>.


==Example==
==Example==

Revision as of 15:58, 14 May 2019

Function to check if specific key is released.

Syntax

mp.keys.isUp(keyCode);

Required Argument

Return Value

  • Boolean - true if the key specified is released, otherwise false.

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.isUp(113) === true) { // 113 is the key code for F2
        mp.gui.chat.push('F2 key is released!');
    } else {
        mp.gui.chat.push('F2 key is not released!');
    }
}, 500);

See also