I find it a better solution to give focus to the modal.
In order to do that, you have to add a tabindex parameter to your modal container, and then set its focus using JavaScript. Once that's done it can receive keyboard events: https://stackoverflow.com/a/6633271/2873507