Gamemode.KeyPress
From GMod Wiki
| Event Hook | |
| Hook Name | KeyPress |
| Syntax | GM:KeyPress( Player player, |
| Description | Runs when a key has been pressed. |
| Returns | Nil |
| Lua State | |
| BBCode | [b][url=wiki.garrysmod.com/?title=Gamemode.KeyPress]Gamemode.KeyPress [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] |
Example
| Description | Message to the console whenever a player presses a key. |
|---|---|
| Used on | |
| Code | function KeyPressed (P, key) Msg (P:GetName().." pressed "..key.."\n") end hook.Add( "KeyPress", "KeyPressedHook", KeyPressed ) |
| Output | When 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
- You can not use this hook to detect KEY_ keys. This is strictly for IN_ keys.