Garry's Mod Wiki

Revision Difference

Player:KeyDown#512706

<function name="KeyDown" parent="Player" type="classfunc">⤶ <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.</description>⤶ <realm>Shared</realm>⤶ <args>⤶ <arg name="key" type="number">The key, see &lt;page&gt;IN&lt;/page&gt;</arg>⤶ </args>⤶ <rets>⤶ <ret name="" type="boolean">isDown</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Prints whenever the first player is holding forward key</description>⤶ <code>⤶ hook.Add("Tick", "KeyDown_Test", function()⤶ if (Entity(1):KeyDown(IN_FORWARD)) then⤶ print("Player is pressing forward!")⤶ end⤶ end)⤶ </code>⤶ <outputfixedwidth>Fixed width</outputfixedwidth>⤶ <output>⤶ Player is pressing forward!⤶ Player is pressing forward!⤶ Player is pressing forward!⤶ Player is pressing forward!⤶ </output>⤶ ⤶ </example>