stopPropagation doesn't work if key Ctrl is used instead of Mod

I’m trying to override CodeMirror default key by just adding my own keymap with High precedence and stopPropagation, preventDefault both true.
Now, if I map a shortcut with Ctrl+Enter then it runs my code and then adds a new line because of the shortcut Mod+Enter. I was expecting Mod+Enter to have not run because I have stopped propagation.
How to handle this?

If you are on a Mac machine, Mod-Enter doesn’t match Ctrl-Enter presses. If you aren’t, the two are exactly the same and I think there is some issue with your observation.

This is from the debugger. My function is taking the precedence. But despite stopPropagation and preventDefault, it is adding a new line. And I’m using windows

I checked the CodeMirror code if (cmd(view, event)) { and found this. Essentially, custom commands has to return true to make stopPropagation work.
Thank you for you reply. It works now after adding return true.

Hi @marijn,
Will Compartment() work for dynamic keymaps also? I’ve a scenario where I want to reconfigure the shortcuts dynamically based on user preference.

Yes, compartments work for all types of extensions.

Thank you. Works perfectly.