Added a few modifications to the key listener