Player/KeyDown

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

Contents

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

number key

The key, see IN_ Enums

Returns

boolean

isDown

Examples

Example

Prints whenever the first player is holding forward key

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!
Personal tools
Navigation