getKeyState
Client-side
Server-side
Shared
This page is incomplete! Help wanted!
Please finish this page using the corresponding Old Wiki article.
Go to Contribution guidelines for more information.
This function determines if a certain key is pressed or not.
Syntax
getKeyState ( )Code Examples
client
This clientside example prints a message when "p" is pressed, and a different one for the "control+p" combination.
-- define a function that outputs a message if control is pressed, and a different one if it isn'tfunction printMessageFunction() -- if the left or right control keys are pressed, the user has pressed the "lctrl + p" combo. if getKeyState("lctrl") or getKeyState("rctrl") then outputChatBox ("You have pressed 'Left Control + P'.") -- if none of those were pressed, the player just pressed the "p" key. else outputChatBox ("You have pressed 'p'.") endend-- bind the "p" key to our functionbindKey("p", "down", printMessageFunction)See Also
Input Functions
- addCommandHandler
- bindKey
- executeCommandHandler
- getAnalogControlState
- getBoundKeys
- getCommandHandlers
- getCommandsBoundToKey
- getFunctionsBoundToKey
- getKeyBoundToCommand
- getKeyBoundToFunction
- getKeyState
- isCapsLockEnabled
- isControlEnabled
- isKeyBound
- removeCommandHandler
- setAnalogControlState
- toggleAllControls
- toggleControl
- unbindKey
Input Events
- onClientCharacter
- onClientClick
- onClientCursorMove
- onClientDoubleClick
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientKey
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
- onClientPaste