Garry's Mod Wiki

Player:KeyPressed

boolean Player:KeyPressed( number key )

Description

Gets whether a key was just pressed this tick.

Arguments

1 number key
Corresponds to an Enums/IN

Returns

1 boolean
Was pressed or not

Example

Prints whenever the first player first starts pressing +forward key (w on QWERTY keyboards).

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

Page Links


Special Pages


Wikis

?

Render Time: 36ms

DB GetPage 3
Generate Html 9
SaveChanges (1) 9
Render Body 0
Render Sidebar 12