Player/KeyPressed

From Garry's Mod
Jump to: navigation, search
 Player:KeyPressed( )

Contents

Description

Gets whether a key was just pressed this tick

Arguments

number key

Corresponds to an IN_ Enums

Returns

boolean

Was pressed or not

Examples

Example

Prints whenever the first player first starts pressing W

hook.Add( "Tick", "CheckPlayer1Forward", function()
   if( Entity( 1 ):KeyPressed( IN_FORWARD )) then
        print( "Ent1 just started moving forward!" )
    end
end )


Personal tools
Navigation