Keys::isUp: Difference between revisions
MrPancakers (talk | contribs) m (Altered wording) |
No edit summary |
||
| Line 1: | Line 1: | ||
Function to check if specific key is released. | |||
== | ==Syntax== | ||
* ''' | <pre>mp.keys.isUp(keyCode);</pre> | ||
===Required Arguments=== | |||
* '''keyCode''': {{RageType|Number}} - [https://keycode.info code of the 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 half-second and outputs the state of the F2 key (pressed or not). | ||
{{ | {{ClientsideCode| | ||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
setInterval(() => { | setInterval(() => { | ||
if (mp.keys.isUp( | if (mp.keys.isUp(113) === true) { // 113 is the key code for F2 | ||
mp.gui.chat.push('F2 key is | mp.gui.chat.push('F2 key is released!'); | ||
} else { | } else { | ||
mp.gui.chat.push('F2 key is | mp.gui.chat.push('F2 key is not released!'); | ||
} | } | ||
}, 500); | }, 500); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | |||
==See also== | ==See also== | ||
{{Keys_functions_c}} | {{Keys_functions_c}} | ||
[[Category:Control]] | |||
[[Category:Client-side Function]] | |||
Revision as of 15:55, 14 May 2019
Function to check if specific key is released.
Syntax
mp.keys.isUp(keyCode);
Required Arguments
- keyCode: Number - code of the key.
Return Value
- Boolean -
trueif the key specified is released, Otherwisefalse.
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);