Garry's Mod Wiki

Revision Difference

Player:KeyDownLast#515860

<function name="KeyDownLast" parent="Player" type="classfunc"> <description>Gets whether a key was down one tick ago.</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">Is key down</ret> </rets> </function> ⤶ <example>⤶ <description>Prints whenever the first player stopped pressing W last tick</description>⤶ <code>⤶ hook.Add( "Tick", "CheckPlayer1Forward", function()⤶ if ( !Entity( 1 ):KeyDown( IN_FORWARD ) ) and Entity( 1 ):KeyDownLast( IN_FORWARD ) then print( "Ent1 is no longer holding W!") end end )⤶ </code>⤶ ⤶ </example>⤶ {{Example⤶ | Description = Prints whenever the first player stopped pressing W last tick⤶ | Code = hook.Add( "Tick", "CheckPlayer1Forward", function()⤶ ```⤶ if ( !Entity( 1 ):KeyDown( IN_FORWARD ) ) and Entity( 1 ):KeyDownLast( IN_FORWARD ) then print( "Ent1 is no longer holding W!") end ```⤶ ⤶ end )⤶ }}