would it be good if i move it inside the keydown handler for the dialog