Player.KeyPressed

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:KeyPressed( Number key )
Description:
Gets whether the key was pressed. Only works once for each press of the key.
Returns: boolean
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.KeyPressed]Player.KeyPressed [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Example

DescriptionThis example will output "Forward" in the console every time the player presses the forward key
Used onNewerShared.png
Code
local players = player.GetAll()
for _, player in ipairs( players ) do
   if( player:KeyPressed( IN_FORWARD ) ) then
      Msg( "You pressed the forward key!\n" )
   end
end
 
OutputN/A


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox