Keys::isUp: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
mNo edit summary
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
<pre>mp.keys.isUp(keyCode);</pre>
<pre>mp.keys.isUp(keyCode);</pre>


===Required Arguments===
===Required Argument===
* '''keyCode''': {{RageType|Number}} - [https://keycode.info code of the key].
* '''keycode''' - hexadecimal code of [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 key].


===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==
An interval that runs every half-second and outputs the state of the F2 key (pressed or not).
An interval that runs every 100ms and outputs the state of the key bound. (F2)
{{ClientsideCode|
{{ClientsideCode|
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
setInterval(() => {
setInterval(() => {
    if (mp.keys.isUp(113) === true) { // 113 is the key code for F2
mp.keys.isUp(0x71)
        mp.gui.chat.push('F2 key is released!');
? mp.gui.chat.push("false")
    } else {
: mp.gui.chat.push("true");
        mp.gui.chat.push('F2 key is not released!');
}, 100);
    }
}, 500);
</syntaxhighlight>
</syntaxhighlight>
}}
}}

Latest revision as of 12:55, 15 January 2025

Function to check if specific key is released.

Syntax

mp.keys.isUp(keyCode);

Required Argument

  • keycode - hexadecimal code of key.

Return Value

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

Example

An interval that runs every 100ms and outputs the state of the key bound. (F2)

Client-Side
setInterval(() => {
	mp.keys.isUp(0x71)
		? mp.gui.chat.push("false")
		: mp.gui.chat.push("true");
}, 100);

See also