Refactor
Improve context checking for key bindings