Comments (7)
@ChrisFan You can do a chord like this:
var KM = monaco.KeyMod;
var KC = monaco.KeyCode;
editor.addCommand(KM.chord(KM.CtrlCmd | KC.KEY_K, KM.CtrlCmd | KC.KEY_M), function() {
//...
});
from monaco-editor.
Ah, good find! Works perfectly for me, as well. Thanks!!
from monaco-editor.
@ptyork Your code works for me if I don't use an array:
var myBinding = editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S, function() {
alert('SAVE pressed!');
});
from monaco-editor.
Let me clarify that this is with FF. Seems to work without issue in Chrome and Edge (Edge seemingly not pre-binding Ctrl+S). And works with or without the array for me anyway.
Incidentally, while I think this may be a real bug, is there a discussion forum for this so that I don't clutter the issue log with other questions?
from monaco-editor.
Ok, I could reproduce in FF. I have debugged into the keybindingServiceImpl
and we do call e.preventDefault()
. Here is what I could find, seems to be a problem with FF and calling alert
: http://stackoverflow.com/questions/14860759/cant-override-ctrls-in-firefox-using-jquery-hotkeys/14861031#14861031
So changing your snippet to the following works for me:
var myBinding = editor.addCommand(monaco.KeyMod.CtrlCmd | monaco.KeyCode.KEY_S, function() {
console.log('SAVE pressed!');
});
We haven't set up a forum, so please feel free to continue creating issues. I don't think that is a problem, the main advantage is that they are searchable.
from monaco-editor.
is it possible to bind [⌘K W]
?
editor.addCommand(CtrlCmd | KEY_K | KEY_W, () => {
// this is not working
});
from monaco-editor.
add this command on editorInstance itself...
THANKS & IT WORKS LIKE CHARM
from monaco-editor.
Related Issues (20)
- [Bug] Cannot run monaco with lit and webpack HOT 2
- [Feature Request] Update samples - (samples using old version of monaco-editor)
- [Bug] error when selecting text with mouse in shadow dom HOT 2
- [Bug] Regression - diff glyphs no longer render in the correct position
- Add real world user showcase
- [Bug]-Did the monaco editor suggestWidget support fixed positioning, where the position was set dynamically following the cursor move
- [Bug] "No suggestions." shown when suggestions are provided at end of current token
- [Bug] Explicitly triggered inline completions with promise occasionally raising Uncaught (in promise) Canceled: Canceled
- editor Suggest whether the Widget can be inserted into the body or under the specified element
- [Bug] The RegExp d Modifier was not support on Safari 14 const markRegex = /\bMARK:\s*(.*)$/d; HOT 1
- [Bug] incorrect hightlight of markdown code when an image is a link
- [Bug] ee.create is not a function HOT 3
- [Bug] Typing is blocked after right click in the editor when set `contextmenu` to false
- [Bug] "browser-esm-vite-react" code sample not working with monaco-editor v0.49.0 HOT 2
- bracketPairColorization is invalid.
- [Bug] Folding not working for big json objects
- [Bug] TS2786: Editor cannot be used as a JSX component. HOT 1
- [Bug] colorizeElement method doesn't color the whole text if domNode has more than one #text child
- [Bug] The decorator created does not take effect
- Add support for code debug
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monaco-editor.