PrismJS / live

Prism Live: Lightweight, extensible editable code editors. A work in progress, try it out at your own risk (and report bugs!) :)
https://live.prismjs.com
MIT License
105 stars 28 forks source link

Fix code editor swallowing "(Command) + `" on Safari #38

Closed jaladh-singhal closed 1 year ago

jaladh-singhal commented 1 year ago

Fixes #37

On keydown events for pairs (like ', ", (, `, etc.), the custom handling is preventing default browser handling of the keydown event at the end which is necessary for window switching. So fixed the condition to make sure it only happens if keydown of such pair characters was not in combination of keydown of superKey (which is "Cmd" in case of Mac).

Why this bug is only in safari? Chrome didn't have this problem with "Cmd + `" shortcut because it doesn't allow JS running in browser to catch "`" key press event if it was pressed after "Cmd", only "Cmd" is caught. But safari allows JS to catch both - "Cmd" keypress and then "`" keypress (even when it was pressed in combination).