Garry's Mod Wiki

Revision Difference

Player:KeyPressed#518026

<function name="KeyPressed" parent="Player" type="classfunc"> <description>Gets whether a key was just pressed this tick</description> <realm>Shared</realm> <args> <arg name="key" type="number">Corresponds to an &lt;page&gt;IN&lt;/page&gt;</arg>⤶ <arg name="key" type="number">Corresponds to an <page>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> <code> hook.Add( "Tick", "CheckPlayer1Forward", function() if( Entity( 1 ):KeyPressed( IN_FORWARD )) then print( "Ent1 just started moving forward!" ) end end ) </code> </example>