Tidied up key binding code