Bind: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(revamped totally)
Line 1: Line 1:
This is a [[console command]] that lets you bind other console commands to a key.
{{toc-right}}
----
'''<code>bind</code>''' is a [[console command]] that lets you bind other console commands to a key.
{{syntax|bind <key> <command(s)>}}


{{CCExample|If you wanted to make the '''V''' key toggle [[noclip|noclipping]], you would type in console: |bind v "noclip"}}
{{bug|Commands like <code>+forward</code> may not work when in multi-command chains inside binds. See {{ent|alias}} for possible solutions.}}


{{CCExample|If you wanted to make the '''H''' key make you say ''"Hello."'' in chat, you would type in console: |bind h "say Hello."}}
==Syntax==
<pre>bind KEY COMMANDS</pre>


{{CCExample|If you wanted to make the '''L''' key prepare your screen for [[How To Take Screenshots|screenshots]], you would type in console: |bind l "cl_drawhud 0;crosshair 0;impulse 200"}}
If you wanted to make your '''v''' key toggle {{ent|noclip}}, you would type <code>bind "v" "noclip"</code> in the console.


Quotation marks around strings are not always required, but should be used to ensure that special characters, such as spaces and semicolons, are not misinterpreted. For number-only strings, quotation marks should not be used.
{{note|Quotation marks around strings are not always required, but should be used to ensure that special characters, such as spaces and semicolons, are not misinterpreted.}}


[[Category:Console Commands]]
==Special Keys==
==Special Keys==
* tab
{{todo|Explanations for some keys. Maybe some kind of diagram?}}
* enter
{{ExpandBox|
* escape
*tab
* space
*enter
* backspace
*escape
* uparrow
*space
* downarrow
*backspace
* leftarrow
*uparrow
* rightarrow
*downarrow
* alt
*leftarrow
* ctrl
*rightarrow
* shift
*alt
* ins
*ctrl
* del
*shift
* pgdn
*ins
* pgup
*del
* home
*pgdn
* end
*pgup
* kp_home
*home
* kp_uparrow
*end
* kp_pgup
*kp_home
* kp_leftarrow
*kp_uparrow
* kp_5
*kp_pgup
* kp_rightarrow
*kp_leftarrow
* kp_end
*kp_5
* kp_downarrow
*kp_rightarrow
* kp_pgdn
*kp_end
* kp_enter
*kp_downarrow
* kp_ins
*kp_pgdn
* kp_del
*kp_enter
* kp_slash
*kp_ins
* kp_multiply
*kp_del
* kp_minus
*kp_slash
* kp_plus
*kp_multiply
* capslock
*kp_minus
* joy'''''1-4'''''
*kp_plus
* aux'''''1-31'''''
*capslock
* mwheeldown
*joy'''''1-4'''''
* mwheelup
*aux'''''1-31'''''
* mouse'''''1-5'''''
*mwheeldown
* pause
*mwheelup
*mouse'''''1-5'''''
*pause
}}
 
==Related console commands==
==={{todo|binds_per_command}}===
 
===BindToggle===
A convenient command for toggling a [[Cvar]] on or off by pressing a key. Functionally identical to <code>bind KEY "increment var CVAR 0 1 1"</code>.
 
Syntax:<pre>BindToggle KEY CVAR</pre>
 
If you wanted your '''p''' key to turn {{ent|sv_cheats}} on or off, you would type <code>BindToggle p sv_cheats</code>.
 
===bind_mac===
Functions identically to <code>bind</code> except it only affects Mac OS users, not Windows.
 
{{todo|What about Linux...?}}
 
===unbind===
The opposite of <code>bind</code>. Sets a key to do nothing.
 
Syntax:<pre>unbind KEY</pre>
 
To make your left click do nothing, you would type <code>unbind MOUSE1</code>.
 
===unbind_mac===
Functions identically to <code>unbind</code> except it only affects Mac OS users, not Windows.
 
{{todo|What about Linux...?}}
 
===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"
</pre>}}
 
===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</pre>
 
Example input and output from Half-Life 2:
<pre>] key_findbinding slot
"1" = "slot1"
"2" = "slot2"
"3" = "slot3"
"4" = "slot4"
"5" = "slot5"
"6" = "slot6"
</pre>
 
==={{todo|key_updatelayout}}===


==See Also==
==See Also==
[[Console Command List]]
*[[Console Command List]]
 
[[Category:Console Commands]]

Revision as of 05:36, 14 July 2018

bind is a console command that lets you bind other console commands to a key.

Icon-Bug.pngBug:Commands like +forward may not work when in multi-command chains inside binds. See alias for possible solutions.  [todo tested in ?]

Syntax

bind KEY COMMANDS

If you wanted to make your v key toggle noclip, you would type bind "v" "noclip" in the console.

Note.pngNote:Quotation marks around strings are not always required, but should be used to ensure that special characters, such as spaces and semicolons, are not misinterpreted.

Special Keys

Todo: Explanations for some keys. Maybe some kind of diagram?

  • tab
  • enter
  • escape
  • space
  • backspace
  • uparrow
  • downarrow
  • leftarrow
  • rightarrow
  • alt
  • ctrl
  • shift
  • ins
  • del
  • pgdn
  • pgup
  • home
  • end
  • kp_home
  • kp_uparrow
  • kp_pgup
  • kp_leftarrow
  • kp_5
  • kp_rightarrow
  • kp_end
  • kp_downarrow
  • kp_pgdn
  • kp_enter
  • kp_ins
  • kp_del
  • kp_slash
  • kp_multiply
  • kp_minus
  • kp_plus
  • capslock
  • joy1-4
  • aux1-31
  • mwheeldown
  • mwheelup
  • mouse1-5
  • pause

Related console commands

Todo: binds_per_command

BindToggle

A convenient command for toggling a Cvar on or off by pressing a key. Functionally identical to bind KEY "increment var 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.

bind_mac

Functions identically to bind except it only affects Mac OS users, not Windows.

Todo: What about Linux...?

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 Mac OS users, not Windows.

Todo: What about Linux...?

unbindall

The infamous command that unbinds all the keys.

Tip.pngTip: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:


] 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"

Todo: key_updatelayout

See Also