OnKeyPress: Difference between revisions
From Onset Developer Wiki
Created page with "{{Info|Event|Client|1.0}} {{FuncDescription|Called when the player presses a key. You can use IsCtrlPressed and IsShiftPressed to check if it is a key combination.}}..." |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Event|Client|1.0}} | {{Info|Event|Client|1.0}} | ||
{{FuncDescription|Called when the player presses a key. You can use [[IsCtrlPressed]] and [[IsShiftPressed]] to check if it is a key combination.}} | {{FuncDescription|Called when the player presses a key. You can use [[IsCtrlPressed]] and [[IsShiftPressed]] to check if it is a key combination.<br>Use [[OnKeyRelease]] to detect when they release the key.}} | ||
{{FuncSyntax|OnKeyPress(key)}} | {{FuncSyntax|OnKeyPress(key)}} |
Revision as of 12:59, 23 March 2019
Description
Called when the player presses a key. You can use IsCtrlPressed and IsShiftPressed to check if it is a key combination.
Use OnKeyRelease to detect when they release the key.
Syntax
OnKeyPress(key)
Parameters
- key
The name of the key as a string.
Example
function OnKeyPress(key)
AddPlayerChat(key)
if key == "Tab" then
AddPlayerChat("You have pressed TAB!")
end
end
AddEvent("OnKeyPress", OnKeyPress)
See also
Game
- OnGameTick
- OnGameLanguageChange
- OnSteamOverlayActivated
- OnResolutionChange
- OnRenderHUD
- OnShowMainMenu
- OnHideMainMenu
- OnWhitelistAccepted
Vehicle
- OnVehicleStreamIn
- OnVehicleStreamOut
- OnPlayerStartEnterVehicle
- OnPlayerStartExitVehicle
- OnPlayerEnterVehicle
- OnPlayerLeaveVehicle
- OnPlayerToggleVehicleLight
- OnPlayerToggleVehicleNitro
- OnPlayerToggleVehicleHorn
- OnVehicleBackfire
Player
- OnPlayWeaponHitEffects
- OnPlayerStreamIn
- OnPlayerStreamOut
- OnPlayerSwitchCamera
- OnPlayerEnterWater
- OnPlayerLeaveWater
- OnPlayerDeath
- OnPlayerChatCommand
- OnPlayerChat
- OnPlayerSpawn
- OnPlayerCrouch
- OnPlayerEndCrouch
- OnPlayerEndFall
- OnPlayerFall
- OnPlayerTalking
- OnPlayerToggleAim
- OnPlayerFootstep
Weapon
Parachuting
- OnPlayerParachuteLand
- OnPlayerSkydiveCrash
- OnPlayerCancelSkydive
- OnPlayerSkydive
- OnPlayerParachuteOpen
- OnPlayerParachuteClose
Key
NPC
Object
- OnObjectStreamIn
- OnObjectStreamOut
- OnObjectHit
- OnPlayerEndEditObject
- OnPlayerBeginEditObject
- OnObjectModelChange
Package
Pickup
Text
Vehicle
- OnVehicleStreamIn
- OnVehicleStreamOut
- OnPlayerStartEnterVehicle
- OnPlayerStartExitVehicle
- OnPlayerEnterVehicle
- OnPlayerLeaveVehicle
- OnPlayerToggleVehicleLight
- OnPlayerToggleVehicleNitro
- OnPlayerToggleVehicleHorn
- OnVehicleBackfire