Skip to content

Raw Keys Client

The Raw Keys module allows you to register and remove key listeners for raw keyboard events. It supports multiple keyboard layouts (QWERTY and AZERTY) by checking the jo_libs:keyboard_layout convar, which defaults to "QWERTY". Callbacks will be triggered when a key is pressed or released.

JO Functions

jo.rawKeys.listen()

Registers a listener for a specific key. When the key is pressed or released, the provided callback function is executed with a boolean value indicating the event state (true for pressed, false for released).

Syntax

lua
jo.rawKeys.listen(key, callback)

Parameters

key : string

The identifier of the key to listen for. This should correspond to one of the keys defined in the keyboard mappings (e.g., "A", "B", "F1", etc.).

callback : function

The function to be executed when the key event occurs. It receives one parameter:
booleantrue when the key is pressed, false when it is released.

Example

lua
jo.rawKeys.listen("A", function(pressed)
  if pressed then
    print("Key A pressed")
  else
    print("Key A released")
  end
end)

jo.rawKeys.remove()

Removes the listener associated with the specified key. Use this function to stop listening for events on a key when it is no longer needed.

Syntax

lua
jo.rawKeys.remove(key)

Parameters

key : string

The identifier of the key for which the listener should be removed.

Example

lua
jo.rawKeys.remove("A")

Configuration

Setting Keyboard Layout

  • Keyboard Layouts:
    The module supports both QWERTY and AZERTY layouts. The layout in use is determined by the jo_libs:keyboard_layout convar. If set to "AZERTY", the corresponding key mappings are applied automatically.
    You can set the keyboard layout in your server configuration by adding the following line to your server.cfg:

    cfg
    setr jo_libs:keyboard_layout "AZERTY"
    ## or
    setr jo_libs:keyboard_layout "QWERTY"

Keys

Keyboard keys mapping

Input ParameterInput Description
BACKBackspace key
TABTab key
CLEARClear key
RETURNEnter/Return key
SHIFTShift key
CTRLControl key
MENUAlt/Menu key
PAUSEPause key
CAPITALCaps Lock key
EscEscape key
SPACESpace bar
PAGEUPPage Up key
PAGEDOWNPage Down key
ENDEnd key
HOMEHome key
LEFTLeft arrow key
UPUp arrow key
RIGHTRight arrow key
DOWNDown arrow key
PRINTPrint Screen key
INSERTInsert key
DELETEDelete key
LWINLeft Windows/OS key
RWINRight Windows/OS key
NUMLOCKNum Lock key
L SHIFTLeft Shift key
R SHIFTRight Shift key
L CTRLLeft Control key
R CTRLRight Control key
L ALTLeft Alt key
R ALTRight Alt key
0Number key 0
1Number key 1
2Number key 2
3Number key 3
4Number key 4
5Number key 5
6Number key 6
7Number key 7
8Number key 8
9Number key 9
NUMPAD0Numpad key 0
NUMPAD1Numpad key 1
NUMPAD2Numpad key 2
NUMPAD3Numpad key 3
NUMPAD4Numpad key 4
NUMPAD5Numpad key 5
NUMPAD6Numpad key 6
NUMPAD7Numpad key 7
NUMPAD8Numpad key 8
NUMPAD9Numpad key 9
NUMPAD_MULTIPLYNumpad Multiply key
NUMPAD_ADDNumpad Add key
NUMPAD_SUBTRACTNumpad Subtract key
NUMPAD_DECIMALNumpad Decimal key
ALetter key A
BLetter key B
CLetter key C
DLetter key D
ELetter key E
FLetter key F
GLetter key G
HLetter key H
ILetter key I
JLetter key J
KLetter key K
LLetter key L
MLetter key M
NLetter key N
OLetter key O
PLetter key P
QLetter key Q
RLetter key R
SLetter key S
TLetter key T
ULetter key U
VLetter key V
WLetter key W
XLetter key X
YLetter key Y
ZLetter key Z
F1Function key F1
F2Function key F2
F3Function key F3
F4Function key F4
F5Function key F5
F6Function key F6
F7Function key F7
F8Function key F8
F9Function key F9
F10Function key F10
F11Function key F11
F12Function key F12
F13Function key F13
F14Function key F14
F15Function key F15
F16Function key F16
F17Function key F17
F18Function key F18
F19Function key F19
F20Function key F20
F21Function key F21
F22Function key F22
F23Function key F23
F24Function key F24
;Semicolon key (OEM_1 punctuation)
+Plus/Equals key
,Comma key
-Minus key
;Period key
/Slash key
`Grave accent/Tilde key
[Left bracket key
\Backslash key
]Right bracket key
'Apostrophe/Quote key
BROWSER_BACKBrowser Back key
BROWSER_FORWARDBrowser Forward key
BROWSER_REFRESHBrowser Refresh key
BROWSER_STOPBrowser Stop key
BROWSER_SEARCHBrowser Search key
BROWSER_FAVORITESBrowser Favorites key
BROWSER_HOMEBrowser Home key
VOLUME_MUTEVolume Mute key
VOLUME_DOWNVolume Down key
VOLUME_UPVolume Up key
MEDIA_NEXT_TRACKMedia Next Track key
MEDIA_PREV_TRACKMedia Previous Track key
MEDIA_STOPMedia Stop key
MEDIA_PLAY_PAUSEMedia Play/Pause key
LAUNCH_MAILLaunch Mail key
LAUNCH_MEDIA_SELECTLaunch Media Select key
LAUNCH_APP1Launch Application 1 key
LAUNCH_APP2Launch Application 2 key
OEM_8OEM specific key
OEM_102OEM specific key (often <> or extra backslash on some keyboards)
PROCESSKEYProcess key (for handling input methods)
PACKETPacket key (IME related)
ATTNAttn key (Attention)
CRSELCrsel key (Cursor Select)
EXSELExsel key (Execute Select)
EREOFErase EOF key
PLAYPlay key
ZOOMZoom key
NONAMEUnnamed key (undefined)
PA1PA1 key
OEM_CLEARClear key (often on the numeric keypad)

Last updated: