Keys::isDown: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| (One intermediate revision by one other user not shown) | |||
| Line 4: | Line 4: | ||
<pre>mp.keys.isDown(keyCode);</pre> | <pre>mp.keys.isDown(keyCode);</pre> | ||
===Required | ===Required Argument=== | ||
* ''' | * '''keycode''' - hexadecimal code of [https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731 key]. | ||
===Return Value=== | ===Return Value=== | ||
| Line 11: | Line 11: | ||
==Example== | ==Example== | ||
An interval that runs every | 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(() => { | ||
mp.keys.isUp(0x71) | |||
? mp.gui.chat.push("true") | |||
: mp.gui.chat.push("false"); | |||
}, 100); | |||
}, | |||
</syntaxhighlight> | </syntaxhighlight> | ||
}} | }} | ||
Latest revision as of 12:56, 15 January 2025
Function to check if specific key is pressed down.
Syntax
mp.keys.isDown(keyCode);
Required Argument
- keycode - hexadecimal code of key.
Return Value
- Boolean -
trueif the key specified is pressed, Otherwisefalse.
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("true")
: mp.gui.chat.push("false");
}, 100);