Garry's Mod Wiki

Player:KeyDown

boolean Player:KeyDown( number key )

Description

Gets whether a key is down. This is not networked to other players, meaning only the local client can see the keys they are pressing.

Arguments

1 number key
The key, see Enums/IN

Returns

1 boolean
isDown ?

Example

Prints whenever the first player is holding +forward key (w on QWERTY keyboards).

hook.Add( "Tick", "KeyDown_Test", function() if ( Entity( 1 ):KeyDown( IN_FORWARD ) ) then print( "Player is pressing forward!" ) end end )
Output:
Player is pressing forward! Player is pressing forward! Player is pressing forward! Player is pressing forward!

Page Links


Special Pages


Wikis

?

Render Time: 73ms

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