Closed kennethcassel closed 2 years ago
you may implement it like this (based on livecodes editor/monaco.ts)
const keyCodes = {
CtrlEnter: monaco.KeyMod.CtrlCmd | monaco.KeyCode.Enter,
Enter: monaco.KeyCode.Enter,
UpArrow: monaco.KeyCode.UpArrow,
DownArrow: monaco.KeyCode.DownArrow,
};
const addKeyBinding = (label: string, keybinding: any, callback: () => void) => {
editor.addAction({
id: label,
label,
keybindings: [keybinding],
precondition: '!suggestWidgetVisible && !markersNavigationVisible && !findWidgetVisible',
run: callback,
});
};
// use it like that
addKeyBinding('run', keyCodes.CtrlEnter, async () => {
await run();
});
I am working on it.
And the way I am approaching it is.
Add an event listener to window.
And when ctrl + enter or cmd + enter is clicked I am firing method runCode
Thanks @shadab14meb346 for closing this with #81
Is your feature request related to a problem? Please describe.
Yup, when playing with the code editor, it'd be much nicer to run the code via a cmd + enter or ctrl+enter instead of having to use the mouse.
Describe the solution you'd like Run code on CMD + Enter, or CTRL + Enter
Describe alternatives you've considered Using the mouse every time to click the button to run my code