Related to MC-302450 .
If you want to use the Esc key to perform a certain action in-game, you can’t do that without manually editing options.txt. Clicking on a keybind option then pressing Esc will simply unbind the control from whatever key, rather than assigning it to the escape key.
To fix: make pressing Esc correctly assign that control to that key. A new user interface button could also be added to unbind each control, if this functionality is desired.
Thank you for your report!
We're actually already tracking this issue at MC-302450, so I will resolve and link this ticket as a duplicate.
I suggest also to browse through the main issue for potential fixes.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
Quick Links:
📓 Issue Guidelines – 💬 Mojang Support – 📧 Suggestions – 📖 Minecraft Wiki