The pause button is bound to the wrong key. It is bound to the physical escape key and not the escape key set in the keyboard layout. This is not possible on Windows, but is on Linux and *BSD. This is on X11 as (AFAIK) Java still does not support wayland and runs through xwayland.
Demonstration:
To reproduce:
Install Minecraft on a *nix machine running X (and not wayland)
Run the following command to set the option to swap caps and escape:
$ setxkbmap -option caps:swapescape
Launch Minecraft
The game will now still pause when you hit the key labelled escape rather than the key that the rest of the system treats as escape. It will also toggle caps lock.
Linked issues
Comments

A workaround I've found is to use something like keyd to intercept and change the keyboard events. If you're wondering about input delay I haven't noticed any, although that may be an issue for really low-end computers.
Duplicate of MC-252336.
Thank you for your report!
We're tracking this issue in MC-252336, so this ticket is being resolved and linked as a duplicate.
If you would like to add a vote and any extra information to the main ticket it would be appreciated.
If you haven't already, you might like to make use of the search feature to see if the issue has already been mentioned.
Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki
Could you expand this issue more detail by adding some screenshots and videos for this issue?