Bind

It is used to bind a key to one or several other commands. Typically, when keys are bound, the corresponding command is stored in which is ran when the engine starts, leading to binds staying active between sessions unless is set to read-only.
==Syntax==
===Basic Syntax===
The basic syntax for the command is as follows:
For example, after running , pressing would execute the command . Additionally, binding a key to a semicolon-separated list of commands in quotation marks would cause all commands to be executed, because everything within quotation marks is interpreted as a single argument. After running , then pressing mouse1, would be run, followed by .
===+/- Commands===
If the first character in the command/string that the key is bound to is , then after releasing the key, the same string of commands is executed, except the first character is replaced with . For example, running will cause to be run when is pressed, then to be run when is unpressed. Consequently, there are some cases where the result of pressing a key are different from what is intuitive. Running will cause to be run when is pressed, but causes to be run when is unpressed, causing to be run, rather than . The command can be used in conjunction with to yield different results. To make the W key instead run when pressed, and run when unpressed, the following commands can be used:
alias +w_pressed "+forward; +attack"
alias -w_pressed "-forward; -attack"
bind w +w_pressed
==Special Keys==
 System Commands, Modifier Keys, Other
Bind name 	Key
f1-12 	Function key to
escape 	(Escape)
tab 	Tabulator
capslock 	
shift 	(Left side)
rshift 	(Right side)
ctrl 	(Left side)
rctrl 	(Right side)
alt 	(Left side)
ralt 	(Right side)
space 	Spacebar
backspace 	
enter 	
semicolon 	Semicolon ()
lwin 	(Left side)
rwin 	(Right side)
apps 	
numlock 	
scrolllock	
 Navigation Keys
Bind name 	Key
uparrow 	Up Arrow
downarrow 	Down Arrow
leftarrow 	Left Arrow
rightarrow	Right Arrow
ins 	
del 	
pgdn 	
pgup 	
home 	
end 	
pause 	(or )
 Number Pad
Bind name 	Key
kp_end 	Keypad 1
kp_downarrow 	Keypad 2
kp_pgdn 	Keypad 3
kp_leftarrow 	Keypad 4
kp_5 	Keypad 5
kp_rightarrow	Keypad 6
kp_home 	Keypad 7
kp_uparrow 	Keypad 8
kp_pgup 	Keypad 9
kp_enter 	Keypad Enter
kp_ins 	Keypad 0
kp_del 	Keypad .
kp_slash 	Keypad /
kp_multiply 	Keypad *
kp_minus 	Keypad -
kp_plus 	Keypad +
 Mouse Buttons
Bind name 	Key
mwheeldown	Mouse - Scroll Down
mwheelup 	Mouse - Scroll Up
mouse1 	(Mouse - Left click)
mouse2 	(Mouse - Right click)
mouse3 	(Mouse - Middle/Wheel click)
mouse4 	(Mouse - Page Back)
mouse5 	(Mouse - Page Forward)
 Gamepad Buttons (//)
Bind name 	Key
Z AXIS POS 	(left trigger) button
Z AXIS NEG 	(right trigger) button
joy1 / A_BUTTON 	button (Cross) button
joy2 / B_BUTTON 	button (Circle) button
joy3 / X_BUTTON 	button (Square) button
joy4 / Y_BUTTON 	button (Triangle) button
joy5 / L_SHOULDER	(left bumper) button button
joy6 / R_SHOULDER	(right bumper) button button
joy7 / BACK 	(Back) button View button (left trigger) button
joy8 / START 	(Start) button button (right trigger) button
joy9 / STICK1 	(Left stick) button Select/Share/Create button
joy10 / STICK2 	(Right stick) button Start/Options button
joy11 	button
joy12 	button
joy13 	button
joy14 	(/ only) - Touchpad
joy15-32 	Other joystick & gamepad buttons.
aux1-32 	Legacy. Maps directly to joy1-32.
pov_up 	D-Pad Up
pov_right 	D-Pad Right
pov_down 	D-Pad Down
pov_left 	D-Pad Left
==Related console commands==
===Binds_per_command===
Set the maximum number of binds per command when on console. Does not apply to desktop.
Syntax:
===BindToggle===
A convenient command for toggling a CVar on or off by pressing a key. Functionally identical to .
Syntax:
If you wanted your p key to turn on or off, you would type .
===Toggle===
Not to be confused with BindToggle. Toggle allows you to toggle values of a convar, instead of the convar's 0/1 state.
For example, toggling between sv_noclipspeed 1 and 5
Syntax:
===Bind_mac===
Functions identically to except it only affects users.
===Unbind===
The opposite of . Sets a key to do nothing.
Syntax:
To make your left click do nothing, you would type .
===Unbind_mac===
Functions identically to except it only affects users.
===unbindall===
The infamous command that unbinds all the keys.
===Key_listboundkeys===
Lists all keys that are bound to something, and what they are bound to.
Example input and output from Half-Life 2:
===Key_findbinding===
Searches through the list of bound keys and returns the ones that have a given substring in the command field.
Syntax:
Example input and output from Half-Life 2:
===Key_updatelayout===
Updates game keyboard layout to current windows keyboard setting. Only works on windows.
This is only useful if your virtual keyboard layout changes in Windows (i.e changing from QWERTY to AZERTY) while the game is running.