CUserCmd.KeyDown

From GMod Wiki

Revision as of 00:00, 1 April 2010 by Xyxen (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Function
Syntax CUserCmd:KeyDown( Integer IN_KEY )
Description:
Returns true if the player is holding down the specified IN_KEY.
Returns: Boolean
In Object: CUserCmd
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=CUserCmd.KeyDown]CUserCmd.KeyDown [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]



Examples

DescriptionTells you if you are holding your forward movement key.
Used onNewerShared.png
Code
local function IsForwardKeyDown( ply )
 
    local cmd = ply:GetCurrentCommand()
 
    if cmd:KeyDown( IN_FORWARD ) then
        ply:ChatPrint( "You are holding down your forward movement key!" )
    end
 
end
hook.Add( "Move", "IsForwardKeyDownExample", IsForwardKeyDown )
 
OutputIf you are holding down your forward movement key (default: W), "You are holding down your forward movement key!" will be printed to your chat box rapidly.


See Also

Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox