capture keydown event to handle escaping in every case