Add arrow key and esc key functionality