Bind: Difference between revisions
Neo Kabuto (talk | contribs) (Added a common example and made syntax match template description) |
No edit summary |
||
(83 intermediate revisions by 12 users not shown) | |||
Line 1: | Line 1: | ||
{{LanguageBar}} | |||
{{this is a|console command|name=bind|engine=GoldSrc|engine1=Source|engine2=Source 2 | |||
{{ | }} | ||
{{toc-right}} It is used to bind a key to one or several other commands. Typically, when keys are bound, the corresponding {{code|bind}} command is stored in {{code|config.cfg}} which is ran when the engine starts, leading to binds staying active between sessions unless {{code|config.cfg}} is set to read-only. | |||
{{ | {{tip|Often times it is difficult to find out which key you have to press to bind the symbol character you desire, as the game's layout is not the same as your computers. You may press your {{code|$}} key and nothing happens ingame, because it thinks you pressed {{code|\}}.<br>To save yourself a headache, you could use the game's keybind menu to find an empty slot and rebind it to whatever key you want to press, to see what the game thinks that key is supposed to be.}} | ||
==Syntax== | |||
===Basic Syntax=== | |||
The basic syntax for the command is as follows: | |||
{{pre|bind <key> [command]}} | |||
For example, after running {{code|bind 1 slot1}}, pressing {{key|1}} would execute the command {{code|slot1}}. 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 {{code|bind mouse1 "slot1; unbind mouse1"}}, then pressing mouse1, {{code|slot1}} would be run, followed by {{code|unbind mouse1}}. | |||
===+/- Commands=== | |||
If the first character in the command/string that the key is bound to is {{code|+}}, then after releasing the key, the same string of commands is executed, except the first character is replaced with {{code|-}}. For example, running {{code|bind w +forward}} will cause {{code|+forward}} to be run when {{key|w}} is pressed, then {{code|-forward}} to be run when {{key|w}} is unpressed. Consequently, there are some cases where the result of pressing a key are different from what is intuitive. Running {{code|bind w "+forward; +attack"}} will cause {{code|+forward;+attack}} to be run when {{key|w}} is pressed, but causes {{code|-forward;+attack}} to be run when {{key|w}} is unpressed, causing {{code|+attack}} to be run, rather than {{code|-attack}}. The {{code|[[alias]]}} command can be used in conjunction with {{code|bind}} to yield different results. To make the W key instead run {{code|+forward; +attack}} when pressed, and run {{code|-forward; -attack}} when unpressed, the following commands can be used: | |||
<source> | |||
alias +w_pressed "+forward; +attack" | |||
alias -w_pressed "-forward; -attack" | |||
bind w +w_pressed | |||
</source> | |||
==Special Keys== | ==Special Keys== | ||
{{note|In {{cs2|4}} the keypad numbers are KP_1, KP_2, KP_3... {{todo|Is this the case for {{source2|4}} in general? this is also true for Deadlock}} }} | |||
{{Note|Some gamepads button (such as {{code|A_BUTTON}}, but not {{code|joy'''''X'''''}}) may be disabled or become non-functional in favor of Steam Input, if the Gamepad UI were enabled (tested on {{hl2|4}}).}} | |||
{{Note|On any controllers other than Xbox, all the Gamepad Buttons binds may work differently, or incorrectly bound (according to Game Controllers Control Panel in Windows). This does not apply to Steam Input or programs such as DS4Windows, which correctly emulates Xbox controller buttons on any other controllers.}} | |||
{{note|While computers themselves can still use {{code|F13}} to {{code|F24}}, source engine does not recognize these keys.}} | |||
{| class="standard-table" style=float:left | |||
|+ System Commands, Modifier Keys, Other | |||
! Bind name | |||
! Key | |||
|- | |||
| f'''1-12''' | |||
| Function key<br>{{Key|F1}} to {{Key|F12}} | |||
|- id="escape" | |||
| escape | |||
| {{key|Esc}} (Escape) | |||
|- id="tab" | |||
| tab | |||
| {{key|Tab}} Tabulator | |||
|- id="capslock" | |||
| capslock | |||
| {{key|Caps Lock}} | |||
|- id="shift" | |||
| shift | |||
| {{key|Shift}} (Left side) | |||
|- id="rshift" | |||
| rshift | |||
| {{key|Shift}} (Right side) | |||
|- id="ctrl" | |||
| ctrl | |||
| {{key|Ctrl}} (Left side) | |||
|- id="rctrl" | |||
| rctrl | |||
| {{key|Ctrl}} (Right side) | |||
* kp_minus | |- id="alt" | ||
| alt | |||
| {{key|Alt}} (Left side) | |||
|- id="ralt" | |||
| ralt | |||
| {{key|Alt}} (Right side) | |||
|- id="space" | |||
| space | |||
| Spacebar | |||
|- id="backspace" | |||
| backspace | |||
| {{key|Backspace}} | |||
|- id="enter" | |||
| enter | |||
| {{key|Enter}} | |||
|- id="semicolon" | |||
| semicolon | |||
| Semicolon ({{Key|;}}) | |||
|- id="lwin" | |||
| lwin | |||
| {{key|Win}} (Left side) | |||
|- id="rwin" | |||
| rwin | |||
| {{key|Win}} (Right side) | |||
|- id="apps" | |||
| apps | |||
| {{key|Menu}} | |||
|- id="numlock" | |||
| numlock | |||
| {{key|Num Lock}} | |||
|- id="scrolllock" | |||
| scrolllock | |||
| {{key|Scroll Lock}} | |||
|} | |||
{| class="standard-table" style=float:left | |||
|+ Navigation Keys | |||
! Bind name | |||
! Key | |||
|- id="uparrow" | |||
| uparrow | |||
| {{Key|Up}} Up Arrow | |||
|- id="downarrow" | |||
| downarrow | |||
| {{Key|Down}} Down Arrow | |||
|- id="leftarrow" | |||
| leftarrow | |||
| {{Key|Left}} Left Arrow | |||
|- id="rightarrow" | |||
| rightarrow | |||
| {{Key|Right}} Right Arrow | |||
|- id="ins" | |||
| ins | |||
| {{Key|Insert}} | |||
|- id="del" | |||
| del | |||
| {{Key|Delete}} | |||
|- id="pgdn" | |||
| pgdn | |||
| {{Key|Page Down}} | |||
|- id="pgup" | |||
| pgup | |||
| {{Key|Page Up}} | |||
|- id="home" | |||
| home | |||
| {{Key|Home}} | |||
|- id="end" | |||
| end | |||
| {{Key|End}} | |||
|- id="pause" | |||
| pause | |||
| {{Key|Pause}} (or {{Key|Pause/Break}}) | |||
|} | |||
{| class="standard-table" style=float:left | |||
|+ Number Pad | |||
! Bind name | |||
! Key | |||
|- id="1" | |||
| kp_end | |||
| Keypad 1 | |||
|- id="2" | |||
| kp_downarrow | |||
| Keypad 2 | |||
|- id="3" | |||
| kp_pgdn | |||
| Keypad 3 | |||
|- id="4" | |||
| kp_leftarrow | |||
| Keypad 4 | |||
|- id="5" | |||
| kp_5 | |||
| Keypad 5 | |||
|- id="6" | |||
| kp_rightarrow | |||
| Keypad 6 | |||
|- id="7" | |||
| kp_home | |||
| Keypad 7 | |||
|- id="8" | |||
| kp_uparrow | |||
| Keypad 8 | |||
|- id="9" | |||
| kp_pgup | |||
| Keypad 9 | |||
|- id="enter" | |||
| kp_enter | |||
| Keypad Enter | |||
|- id="0" | |||
| kp_ins | |||
| Keypad 0 | |||
|- id="delete" | |||
| kp_del | |||
| Keypad . | |||
|- id="slash" | |||
| kp_slash | |||
| Keypad / | |||
|- id="multiply" | |||
| kp_multiply | |||
| Keypad * | |||
|- id="minus" | |||
| kp_minus | |||
| Keypad - | |||
|- id="plus" | |||
| kp_plus | |||
| Keypad + | |||
|} | |||
{| class="standard-table" style=float:left | |||
|+ Mouse Buttons | |||
! Bind name | |||
! Key | |||
|- id="mwheeldown" | |||
| mwheeldown | |||
| Mouse - Scroll Down | |||
|- id="mwheelup" | |||
| mwheelup | |||
| Mouse - Scroll Up | |||
|- id="mouse1" | |||
| mouse1 | |||
| {{Key|LMB}} (Mouse - Left click) | |||
|- id="mouse2" | |||
| mouse2 | |||
| {{Key|RMB}} (Mouse - Right click) | |||
|- id="mouse3" | |||
| mouse3 | |||
| {{Key|MMB}} (Mouse - Middle/Wheel click) | |||
|- id="mouse4" | |||
| mouse4 | |||
| {{Key|MOUSE4}} (Mouse - Page Back) | |||
|- id="mouse5" | |||
| mouse5 | |||
| {{Key|MOUSE5}} (Mouse - Page Forward) | |||
|} | |||
{| class="standard-table" style=float:left | |||
|+ Gamepad Buttons ({{360}}/{{playstation}}/{{Switch}}) | |||
! Bind name | |||
! Key | |||
|- id="Z AXIS POS" | |||
| Z AXIS POS {{src07|only}} | |||
| {{360}} {{Key|LT}} (left trigger) button | |||
|- id="Z AXIS NEG" | |||
| Z AXIS NEG {{src07|only}} | |||
| {{360}} {{Key|RT}} (right trigger) button | |||
|- id="joy1" | |||
| joy'''1''' / A_BUTTON | |||
| {{360}} {{Key|xbox_A}} button<br>{{playstation}} {{Key|ps_Cross}} (Cross) button | |||
|- id="joy2" | |||
| joy'''2''' / B_BUTTON | |||
| {{360}} {{Key|xbox_B}} button<br>{{playstation}} {{Key|ps_Circle}} (Circle) button | |||
|- id="joy3" | |||
| joy'''3''' / X_BUTTON | |||
| {{360}} {{Key|xbox_X}} button<br>{{playstation}} {{Key|ps_Sq}} (Square) button | |||
|- id="joy4" | |||
| joy'''4''' / Y_BUTTON | |||
| {{360}} {{Key|xbox_Y}} button<br>{{playstation}} {{Key|ps_Tri}} (Triangle) button | |||
|- id="joy5" | |||
| joy'''5''' / L_SHOULDER | |||
| {{360}} {{Key|xbox_LB}} (left bumper) button<br>{{playstation}} {{Key|L1}} button<!-- will add proper icon later --> | |||
|- id="joy6" | |||
| joy'''6''' / R_SHOULDER | |||
| {{360}} {{Key|xbox_RB}} (right bumper) button<br>{{playstation}} {{Key|R1}} button<!-- will add proper icon later --> | |||
|- id="joy7" | |||
| joy'''7''' / BACK | |||
| {{360}} {{Key|xbox_back}} (Back) button<br>{{xone}} View button<br>{{playstation}} {{Key|L2}} (left trigger) button | |||
|- id="joy8" | |||
| joy'''8''' / START | |||
| {{360}} {{Key|xbox_start}} (Start) button<br>{{xone}} {{Key|Menu}} button<br>{{playstation}} {{Key|R2}} (right trigger) button | |||
|- id="joy9" | |||
| joy'''9''' / STICK1 | |||
| {{360}} {{Key|xbox_ls}} (Left stick) button<br>{{playstation}} Select/Share/Create button<!-- will add proper icon later --> | |||
|- id="joy10" | |||
| joy'''10''' / STICK2 | |||
| {{360}} {{Key|xbox_rs}} (Right stick) button<br>{{playstation}} Start/Options button<!-- will add proper icon later --> | |||
|- id="joy11" | |||
| joy'''11''' | |||
| {{playstation}} {{Key|L3}} button<!-- will add proper icon later --> | |||
|- id="joy12" | |||
| joy'''12''' | |||
| {{playstation}} {{Key|R3}} button<!-- will add proper icon later --> | |||
|- id="joy13" | |||
| joy'''13''' | |||
| {{playstation|3.1}} button | |||
|- id="joy14" | |||
| joy'''14''' | |||
| {{playstation}} ({{ps4|3.1|nt=0}}/{{ps5|3.1|nt=0}} only) - Touchpad | |||
|- id="joy15-32" | |||
| joy'''15-32''' | |||
| Other joystick & gamepad buttons. | |||
|- id="aux1-32" | |||
| aux'''1-32''' | |||
| Legacy. Maps directly to joy'''1-32'''. | |||
|- id="pov_up" | |||
| pov_up | |||
| D-Pad Up | |||
|- id="pov_right" | |||
| pov_right | |||
| D-Pad Right | |||
|- id="pov_down" | |||
| pov_down | |||
| D-Pad Down | |||
|- id="pov_left" | |||
| pov_left | |||
| D-Pad Left | |||
|} | |||
{{clr}} | |||
==Related console commands== | |||
===binds_per_command=== | |||
Set the maximum number of binds per command when on console. Does not apply to desktop. | |||
Syntax: | |||
{{pre|binds_per_command <number>}} | |||
===BindToggle=== | |||
A convenient command for toggling a [[CVar]] on or off by pressing a key. Functionally identical to {{code|bind <key> "incrementvar <CVar> 0 1 1"}}. | |||
Syntax: | |||
{{pre|BindToggle <key> <cvar>}} | |||
If you wanted your '''p''' key to turn {{ent|sv_cheats}} on or off, you would type {{code|BindToggle p sv_cheats}}. | |||
===toggle=== | |||
Not to be confused with BindToggle. Toggle allows you to toggle ''values'' of a convar, instead of the convar's 0/1 state.<br> | |||
For example, toggling between sv_noclipspeed 1 and 5 | |||
Syntax: | |||
{{pre|bind <key> "toggle <cvar> <value1> <value2>}} | |||
===bind_mac=== | |||
Functions identically to {{code|bind}} except it only affects {{mac|4}} users. | |||
===unbind=== | |||
The opposite of {{code|bind}}. Sets a key to do nothing. | |||
Syntax: | |||
{{pre|unbind <key>}} | |||
To make your left click do nothing, you would type {{code|unbind MOUSE1}}. | |||
===unbind_mac=== | |||
Functions identically to {{code|unbind}} except it only affects {{mac|4}} users. | |||
===unbindall=== | |||
The infamous command that unbinds all the keys. | |||
{{tip|If you do this command (or you're a poor sap that got tricked), you can reset to default bindings in the '''Options''' menu. '''Keyboard, Use Defaults'''.}} | |||
===key_listboundkeys=== | |||
Lists all keys that are bound to something, and what they are bound to. | |||
Example input and output from Half-Life 2: | |||
{{ExpandBox|{{pre| | |||
] key_listboundkeys | |||
"6" {{=}} "slot6" | |||
"1" {{=}} "slot1" | |||
"a" {{=}} "+moveleft" | |||
"2" {{=}} "slot2" | |||
"c" {{=}} "impulse 50" | |||
"3" {{=}} "slot3" | |||
"d" {{=}} "+moveright" | |||
"4" {{=}} "slot4" | |||
"e" {{=}} "+use" | |||
"5" {{=}} "slot5" | |||
"f" {{=}} "impulse 100" | |||
"g" {{=}} "phys_swap" | |||
"q" {{=}} "lastinv" | |||
"w" {{=}} "+forward" | |||
"r" {{=}} "+reload" | |||
"z" {{=}} "+zoom" | |||
"s" {{=}} "+back" | |||
"`" {{=}} "toggleconsole" | |||
"SPACE" {{=}} "+jump" | |||
"NUMLOCK" {{=}} "pause" | |||
"ESCAPE" {{=}} "cancelselect" | |||
"SHIFT" {{=}} "+speed" | |||
"CTRL" {{=}} "+duck" | |||
"ALT" {{=}} "+walk" | |||
"F5" {{=}} "jpeg" | |||
"F6" {{=}} "save quick" | |||
"F9" {{=}} "load quick" | |||
"MOUSE1" {{=}} "+attack" | |||
"MWHEELDOWN" {{=}} "invnext" | |||
"MOUSE2" {{=}} "+attack2" | |||
"MWHEELUP" {{=}} "invprev" | |||
}}}} | |||
===key_findbinding=== | |||
Searches through the list of bound keys and returns the ones that have a given substring in the command field. | |||
Syntax: | |||
{{pre|key_findbinding <string>}} | |||
Example input and output from Half-Life 2: | |||
{{pre|] key_findbinding slot | |||
"1" {{=}} "slot1" | |||
"2" {{=}} "slot2" | |||
"3" {{=}} "slot3" | |||
"4" {{=}} "slot4" | |||
"5" {{=}} "slot5" | |||
"6" {{=}} "slot6" | |||
}} | |||
===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. | |||
Latest revision as of 14:57, 20 June 2025


bind
is a console command available in all GoldSrc,
Source, and
Source 2 games.
It is used to bind a key to one or several other commands. Typically, when keys are bound, the corresponding bind command is stored in config.cfg which is ran when the engine starts, leading to binds staying active between sessions unless config.cfg is set to read-only.

To save yourself a headache, you could use the game's keybind menu to find an empty slot and rebind it to whatever key you want to press, to see what the game thinks that key is supposed to be.
Syntax
Basic Syntax
The basic syntax for the command is as follows:
bind <key> [command]
For example, after running bind 1 slot1, pressing 1 would execute the command slot1. 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 bind mouse1 "slot1; unbind mouse1", then pressing mouse1, slot1 would be run, followed by unbind mouse1.
+/- 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 bind w +forward will cause +forward to be run when w is pressed, then -forward to be run when w is unpressed. Consequently, there are some cases where the result of pressing a key are different from what is intuitive. Running bind w "+forward; +attack" will cause +forward;+attack to be run when w is pressed, but causes -forward;+attack to be run when w is unpressed, causing +attack to be run, rather than -attack. The alias command can be used in conjunction with bind to yield different results. To make the W key instead run +forward; +attack when pressed, and run -forward; -attack when unpressed, the following commands can be used:
alias +w_pressed "+forward; +attack"
alias -w_pressed "-forward; -attack"
bind w +w_pressed
Special Keys







Bind name | Key |
---|---|
f1-12 | Function key F1 to F12 |
escape | Esc (Escape) |
tab | Tab ⇆ Tabulator |
capslock | ⇪ Caps Lock |
shift | ⇧ Shift (Left side) |
rshift | ⇧ Shift (Right side) |
ctrl | Ctrl (Left side) |
rctrl | Ctrl (Right side) |
alt | Alt (Left side) |
ralt | Alt (Right side) |
space | Spacebar |
backspace | ← Backspace |
enter | ↵ Enter |
semicolon | Semicolon (;) |
lwin | ⊞ Win (Left side) |
rwin | ⊞ Win (Right side) |
apps | ≣ Menu |
numlock | Num Lock |
scrolllock | Scroll Lock |
Bind name | Key |
---|---|
uparrow | ↑ Up Arrow |
downarrow | ↓ Down Arrow |
leftarrow | ← Left Arrow |
rightarrow | → Right Arrow |
ins | Insert |
del | Delete |
pgdn | Page Down |
pgup | Page Up |
home | Home |
end | End |
pause | Pause (or Pause/Break) |
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 + |
Bind name | Key |
---|---|
mwheeldown | Mouse - Scroll Down |
mwheelup | Mouse - Scroll Up |
mouse1 | ![]() |
mouse2 | ![]() |
mouse3 | ![]() |
mouse4 | ![]() |
mouse5 | ![]() |
Bind name | Key |
---|---|
Z AXIS POS (only in ![]() |
![]() |
Z AXIS NEG (only in ![]() |
![]() |
joy1 / A_BUTTON | ![]() ![]() ![]() ![]() |
joy2 / B_BUTTON | ![]() ![]() ![]() ![]() |
joy3 / X_BUTTON | ![]() ![]() ![]() ![]() |
joy4 / Y_BUTTON | ![]() ![]() ![]() ![]() |
joy5 / L_SHOULDER | ![]() ![]() ![]() |
joy6 / R_SHOULDER | ![]() ![]() ![]() |
joy7 / BACK | ![]() ![]() ![]() ![]() |
joy8 / START | ![]() ![]() ![]() ![]() |
joy9 / STICK1 | ![]() ![]() ![]() |
joy10 / STICK2 | ![]() ![]() ![]() |
joy11 | ![]() |
joy12 | ![]() |
joy13 | PlayStation button |
joy14 | ![]() |
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:
binds_per_command <number>
BindToggle
A convenient command for toggling a CVar on or off by pressing a key. Functionally identical to bind <key> "incrementvar <CVar> 0 1 1".
Syntax:
BindToggle <key> <cvar>
If you wanted your p key to turn sv_cheats on or off, you would type BindToggle p sv_cheats.
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 <key> "toggle <cvar> <value1> <value2>
bind_mac
Functions identically to bind except it only affects macOS users.
unbind
The opposite of bind. Sets a key to do nothing.
Syntax:
unbind <key>
To make your left click do nothing, you would type unbind MOUSE1.
unbind_mac
Functions identically to unbind except it only affects macOS 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_listboundkeys "6" = "slot6" "1" = "slot1" "a" = "+moveleft" "2" = "slot2" "c" = "impulse 50" "3" = "slot3" "d" = "+moveright" "4" = "slot4" "e" = "+use" "5" = "slot5" "f" = "impulse 100" "g" = "phys_swap" "q" = "lastinv" "w" = "+forward" "r" = "+reload" "z" = "+zoom" "s" = "+back" "`" = "toggleconsole" "SPACE" = "+jump" "NUMLOCK" = "pause" "ESCAPE" = "cancelselect" "SHIFT" = "+speed" "CTRL" = "+duck" "ALT" = "+walk" "F5" = "jpeg" "F6" = "save quick" "F9" = "load quick" "MOUSE1" = "+attack" "MWHEELDOWN" = "invnext" "MOUSE2" = "+attack2" "MWHEELUP" = "invprev"
key_findbinding
Searches through the list of bound keys and returns the ones that have a given substring in the command field.
Syntax:
key_findbinding <string>
Example input and output from Half-Life 2:
] key_findbinding slot "1" = "slot1" "2" = "slot2" "3" = "slot3" "4" = "slot4" "5" = "slot5" "6" = "slot6"
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.