properly handle the esc key