overriding certain default keymaps

Hello! In my usecase, I’d like to keep majority of the (default keymaps and override some of them. Say for instance, Cmd-Enter to do something else. I added my own keymap for that with keymap.of, but after completing my custom function, it adds a new line. Is there a way to do so or prevent the default from running? Thank you!

You can tweak the precedence of your keymap using Prec which is exported by @codemirror/state to tweak the order of execution of your key bindings. To make sure your binding runs earlier than any other bindings for the same key order you can wrap your binding in Prec.highest

import { Prec } from "@codemirror/state";

      { key: "Mod-Enter", run: Command }

The default key maps can be forund here:


that worked. thank you!

1 Like

thanks man, it helps a lot, search for answer for a day

1 Like