Player.KeyDown

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:KeyDown( Integer key )
Description:
Gets whether the key was pressed. Continues to return true while the player holds the key.
Returns: boolean
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.KeyDown]Player.KeyDown [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThis example will continually output "Forward" in the console while the player holds the forward key down.
Used onNewerShared.png
Code
local players = player.GetAll()
for _, player in ipairs( players ) do
   if( player:KeyDown( 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