Keys::isUp: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "Returns true if the key specific is not pressed. Otherwise, returns false. ==Parameters== * '''keycode''' - code of the key (Number). ==Example== An interval that runs every...")
 
mNo edit summary
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
Returns true if the key specific is not pressed. Otherwise, returns false.
Function to check if specific key is released.  


==Parameters==
==Syntax==
* '''keycode''' - code of the key (Number).
<pre>mp.keys.isUp(keyCode);</pre>
 
===Required Argument===
* '''keycode''' - hexadecimal code of [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 key].
 
===Return Value===
* {{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|
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
setInterval(() => {
setInterval(() => {
    if (mp.keys.isUp(112) === true) { // 112 is the key code for F2
mp.keys.isUp(0x71)
        mp.gui.chat.push('F2 key is not pressed!');
? mp.gui.chat.push("false")
    } else {
: mp.gui.chat.push("true");
        mp.gui.chat.push('F2 key is pressed!');
}, 100);
    }
}, 500);
</syntaxhighlight>
</syntaxhighlight>
}}


==See also==
==See also==
{{KeyBinding_function_c}}
{{Keys_functions_c}}
 
[[Category:Control]]
[[Category:Client-side Function]]

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