SlashCo Wiki

SlashCo.IsKeyPressed

 boolean SlashCo.IsKeyPressed( string name, Player ply, BUTTON_CODE button )

Description

Looks up the current BUTTON_CODE for the given bind and compares it against the given button

Arguments

1string name

Bind

2Player ply

On the Server this is the player which bindings should be used when checking.
On the client this is unused / can be nil

3BUTTON_CODE button

Button to check

Returns

1boolean pressed

Returns true if the given button matches the current bind key

Example

Checking if the ping bind was pressed

hook.Add("PlayerButtonDown", "Example", function(ply, key) -- Check if PING bind was pressed if not SlashCo.IsKeyPressed("PING", ply, key) then return end if SERVER then ply:SurvivorPing() -- Do ping (but this function is only serverside) end end)