Fix bug with key listener when dialog pops up