Half-Life Console Help


Binding Keys and Buttons

When you change one of the keys in the game's controls configurations menus, you're effectively executing the bind console command. The general format for this command is:

bind <key or button> <command1 [; command2] [; command3] . . . [; commandN] >
 
This will cause the game to execute (as if you typed them directly into the console, or executed a script file containing them) the command(s) specified when you press the key or button specified. You may specify only one key or button, and you must specify at least one command. In general you can specify as many commands as you like, but there is a limit to the line length in script files (which is where you'd want to save a really long bind, so keep the total line length under 255 characters, or use the workaround, see Debugging Scripts).

Besides the obvious letter and number keys, you can bind command(s) to mouse buttons (mouse1, mouse2, or mouse3), joystick buttons (joystick1, joystick2, etc.) or the following special keyboard keys: 
 

alt, ctrl, del, downarrow, end, f1-f12 (function keys), home, ins, escape, enter, leftarrow, pause, pgup, pgdn, return, rightarrow, shift, space, tab, uparrow 
 
Note that you can specify the Normal or SHIFT-ed version of a key in a bind command (such as 'a' or 'A', and '4' or "$"), but they both count as the same key (so you can't bind '5' and '%' to different commands).

And no, unfortunately, you can't bind CAPS LOCK, or the numeric keypad keys distinctly from the other number keys. (You CAN bind the numeric keypad keys separately in games based on later versions of the Quake2 engine such as Kingpin and Sin. Half-Life is based more on the Quake1 engine.)

Note that if you bind a key or button to a +command (a command that starts with a plus), Half-Life also automatically binds the corresponding -command to the action of releasing they key or button you bound to the +command. That means if pressing down your space bar starts attacking (+attack), then releasing your space bar STOPS attacking (-attack). If it weren't for this subtlety, pressing the fire button would make your player attack forever. Since the -command is bound and executed automatically, you don't have to worry about it when binding +commands, but you do have to worry about it when using +commands in scripts or aliases.

To unbind ALL binds (be careful with this one, unless it's at the beginning of your autoexec.cfg followed by all of your binds), use unbindall. To unbind just one key, use bind key "" (i.e. bind it to nothing). To see what all of your current binds are, type bindlist. To see what a particular key or button is bound to, type bind key.

Cool, eh? With binds in scripts, you can save different control configurations (and all sorts of other preferences too) in different config files and execute one according to who is playing, or what map, or game type, etc. More importantly, you can have binds that change themselves (i.e. re-bind the key) and binds that execute special commands you can make yourself with aliases. This is how you can make powerful scripts with the console language (keep reading for more details).

Of course, you can execute a command without binding it to a key by just typing the command into the console. Be careful with +commands (commands that start with a plus) when doing this. If you type +attack into the console, your player will start attacking and not stop until you type in -attack. The +command / -command system is handy for writing scripts (i.e. you can shoot once with the mini-script: +attack ; wait ; -attack, but it can be a nightmare if you accidentally put, for example, +jump all by itself (with no - jump) in your autoexec.cfg. 
 
[Previous Page] [Back to Console Index] [Next Page]