Binding a key to a command is fairly straightforward. Basically, you just open your console and type bind key command. Keep in mind that you are 99% of the time binding a console command, so be sure to use the sm_ version of it (ie. sm_menu). There are a few quirks about binding keys though.
An important thing to keep in mind is that if your game crashes, you will lose ALL the binds you have made since the last time it was closed normally. So, if you go setting up 50 binds and then your game crashes, don't say I didn't warn you. It is possible to place all of your binds into a cfg file, but I'm not getting into that discussion here. I'm sure you can google it.
Another thing that sometimes drives me nuts is trying to figure out what HL2 names the keys on my keyboard and my XBox controller.
You can see a full listing on this Key List website.
I know it says it's for Team Fortress 2™ but, I think for all Valve® based games or games that use the Source® engine, the key bindings are the same, if not very similar. At least for keyboard and mouse users.
Bindable Xbox 360 Controller buttons
S1_UP
S1_DOWN
S1_LEFT
S1_RIGHT
STICK1
S2_UP
S2_DOWN
S2_LEFT
S2_RIGHT
STICK2
UP
DOWN
LEFT
RIGHT
BACK
START
A_BUTTON
B_BUTTON
X_BUTTON
Y_BUTTON
L_SHOULDER
R_SHOULDER
L_TRIGGER
R_TRIGGER
Your personal Key Bind Listings
If you had forgotten if a specific key is bound to something and don't just want to press it anyway to find out what it does, just in case, then this where a few of these commands come in handy. All you have to do to see what your F key is bound to (if anything) is type bind f in your console. If it is bound, it will tell you what it is bound to. If it is not bound, it will tell you.
You can also type in key_listboundkeys in console. This will show you ALL of they keys you currently have bound.
If you want to unbind a key (remove its functionality), you can use the unbind command. For instance, say I want my C key to no longer save my checkpoints. I would type unbind c into console. DO NOT USE UNBINDALL! If you do that, you will lose ALL of your binds!
Do I need to use Quotes?
Well, it depends. If the command use you are wanting requires a parameter, then yes. If you are 'chaining' commands together into one bind, yes. Otherwise, you do not need quotes.
Binding chat commands
I want to bind my L key to make me say "You sure are sexy!!" in chat. Well, here is that one...
bind l "say You sure are sexy!!"
I want to bind my T key to use the 'timeleft' chat trigger. No problem!
bind t "say timeleft"