Gamemode.KeyPress

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameKeyPress
SyntaxGM:KeyPress( Player player, IN_KEYS(IN_KEYS) key )
DescriptionRuns when a key has been pressed.
ReturnsNil
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.KeyPress]Gamemode.KeyPress [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Example

DescriptionMessage to the console whenever a player presses a key.
Used onNewerShared.png
Code
function KeyPressed (P, key)
	Msg (P:GetName().." pressed "..key.."\n")
end
 
hook.Add( "KeyPress", "KeyPressedHook", KeyPressed )
OutputWhen a player presses a key the console receives the information on the press e.g. "Devenger pressed 1" (1, being IN_ATTACK, defaulting to left-click; see IN_KEYS)


Additional Notes

See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox