Garry's Mod Wiki

Revision Difference

Player:KeyPressed#527831

<function name="KeyPressed" parent="Player" type="classfunc"> <description>Gets whether a key was just pressed this tick</description>⤶ <description>Gets whether a key was just pressed this tick.</description>⤶ <realm>Shared</realm> <args> <arg name="key" type="number">Corresponds to an <page>Enums/IN</page></arg> </args> <rets> <ret name="" type="boolean">Was pressed or not</ret> </rets> </function> <example> <description>Prints whenever the first player first starts pressing W</description>⤶ <description>Prints whenever the first player first starts pressing <key>+FORWARD</key> key (<key>W</key> on QWERTY keyboards).</description>⤶ <code> hook.Add( "Tick", "CheckPlayer1Forward", function() if ( Entity( 1 ):KeyPressed( IN_FORWARD ) ) then print( "Player1 just started moving forward!" ) end end ) </code> ⤶ </example></example>