Having focus on an input, select or textarea in a modal will prevent it from closing when hitting the escape key.
It makes it possible to close default behavior rather than the modal. For exemple, hitting the escape key on a open select will close it, or will close options for auto-completing a text input.
However it makes it difficult to close the modal, and even more when navigating with the keyboard in a modal filled with form fields.
Having the escape key taking focus out of such fields would make it possible to keep the default behavior, and to allow a second escape close the modal.