Keys

note

To be used with GetPlayerKeys and OnPlayerKeyStateChange.

SA-MP uses bitmasking to determine which keys are pressed and which are not. Here's an article on bitmasking: http://en.wikipedia.org/wiki/Mask_(computing)

MacroValueEmbedding Code (On Foot) (7)Embedding Code (In Vehicle) (7)Default Key (On Foot)Default Key (In Vehicle)
KEY_ACTION1~k~~PED_ANSWER_PHONE~~k~~VEHICLE_FIREWEAPON_ALT~TABALT GR / LCTRL / NUM0
KEY_CROUCH2~k~~PED_DUCK~~k~~VEHICLE_HORN~CH / CAPSLOCK
KEY_FIRE4~k~~PED_FIREWEAPON~~k~~VEHICLE_FIREWEAPON~LCTRL / LMB (Left Mouse Button)LALT
KEY_SPRINT8~k~~PED_SPRINT~~k~~VEHICLE_ACCELERATE~SPACEW
KEY_SECONDARY_ATTACK16~k~~VEHICLE_ENTER_EXIT~~k~~VEHICLE_ENTER_EXIT~ENTERENTER
KEY_JUMP32~k~~PED_JUMPING~~k~~VEHICLE_BRAKE~LSHIFTS
KEY_LOOK_RIGHT64-~k~~VEHICLE_LOOKRIGHT~-E
KEY_HANDBRAKE/KEY_AIM(1)128~k~~PED_LOCK_TARGET~~k~~VEHICLE_HANDBRAKE~RMB (Right Mouse Button)SPACE
KEY_LOOK_LEFT256-~k~~VEHICLE_LOOKLEFT~-Q
KEY_LOOK_BEHIND512~k~~PED_LOOKBEHIND~~k~~VEHICLE_LOOKBEHIND~NUM1 / MMB (Middle Mouse Button - Click the mouse wheel)2
KEY_SUBMISSION512-~k~~TOGGLE_SUBMISSIONS~NUM1 / MMB (Middle Mouse Button - Click the mouse wheel)2 / NUMPAD +
KEY_WALK1024~k~~SNEAK_ABOUT~-LALT-
KEY_ANALOG_UP2048-~k~~VEHICLE_TURRETUP~NUM8(6)NUM8
KEY_ANALOG_DOWN4096-~k~~VEHICLE_TURRETDOWN~NUM2(6)NUM2
KEY_ANALOG_LEFT8192~k~~VEHICLE_LOOKLEFT~~k~~VEHICLE_TURRETLEFT~NUM4NUM4
KEY_ANALOG_RIGHT16384~k~~VEHICLE_LOOKRIGHT~~k~~VEHICLE_TURRETRIGHT~NUM6NUM6
KEY_YES(2)65536~k~~CONVERSATION_YES~~k~~CONVERSATION_YES~YY
KEY_NO(2)131072~k~~CONVERSATION_NO~~k~~CONVERSATION_NO~NN
KEY_CTRL_BACK(2)262144(4)~k~~GROUP_CONTROL_BWD~~k~~GROUP_CONTROL_BWD~HH
UNDEFINED(3)-~k~~GROUP_CONTROL_FWD~~k~~GROUP_CONTROL_FWD~GG
KEY_UP-128~k~~GO_FORWARD~~k~~VEHICLE_STEERUP~UPUP
KEY_DOWN128~k~~GO_BACK~~k~~VEHICLE_STEERDOWN~DOWNDOWN
KEY_LEFT-128~k~~GO_LEFT~~k~~VEHICLE_STEERLEFT~LEFTLEFT
KEY_RIGHT128~k~~GO_RIGHT~~k~~VEHICLE_STEERRIGHT~RIGHTRIGHT

(1) Key not defined in SA:MP includes. You must

#define KEY_AIM KEY_HANDBRAKE

or use KEY_HANDBRAKE.

(2) Supported since 0.3d. Not detectable in earlier versions. This key can not be detected when the player is in spectator mode.

(3) GROUP_CONTROL_FWD cannot be detected in SA-MP, as it used internally to enter vehicles as passenger. However, the gametext definition still exists.

(4) If the key number "262144" does not work, just use key number "2".

(6) Only detected when "JOYPAD" configuration is selected for controller.

(7) Embedding codes only work for client messages, textdraws and gametexts.