Run Javascript function from Vim "normal" mode mapping?

Is there any way to run an arbitrary Javascript function from a Vim normal mode mapping?

Since in normal mode, the text widget is actually disabled, adding keys to the keymap doesn’t work. The Vim.map() command doesn’t let you run arbitrary JS functions (though I tried pretty hard to fool it :slight_smile: ).

The only way I could see to do something approximating what I wanted was to catch the ‘vim-keypress’ event and watch for “C-A-b”. But having done that, I could see no way to keep an actual mapping of C-A-b from firing, too. So that seems a little sub-optimal.

As an aside: Instead of “C-A-b” I’d rather map “C-S-b” or “C-B”, but the normalizer doesn’t let you map shifted letters. (As near as I can tell.)

Edit: removed < & >.

I figured out a way to do this, though I dunno if it’s the best way.

I added a raw event listener on the keydown event in “capture” mode, and if I see a C-A-b I run my Javascript function and cancel the event. (Though, since I can, I changed to using C-S-b, like I actually wanted, instead of C-A-b.)

And I learned a lot about events & keyboard events in the bargain, so, bonus. :slight_smile: