Key Bindings

Does anyone have an idea how to make a key binding system? Also removing a key binding if you enter the same key twice.