mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-04-04 17:56:56 +00:00
Extend keyboard handling
To cope with the Mac’s “meta” key (ie command/⌘) preparatory to trapping command-S
This commit is contained in:
parent
44228ed9f7
commit
b25351e834
@ -48,6 +48,8 @@ exports.parseKeyDescriptor = function(keyDescriptor) {
|
||||
info.shiftKey = true;
|
||||
} else if(s === "alt") {
|
||||
info.altKey = true;
|
||||
} else if(s === "meta") {
|
||||
info.metaKey = true;
|
||||
}
|
||||
// Replace named keys with their code
|
||||
if(namedKeys[s]) {
|
||||
@ -57,4 +59,12 @@ exports.parseKeyDescriptor = function(keyDescriptor) {
|
||||
return info;
|
||||
};
|
||||
|
||||
exports.checkKeyDescriptor = function(event,keyInfo) {
|
||||
return event.keyCode === keyInfo.keyCode &&
|
||||
event.shiftKey === keyInfo.shiftKey &&
|
||||
event.altKey === keyInfo.altKey &&
|
||||
event.ctrlKey === keyInfo.ctrlKey &&
|
||||
event.metaKey === keyInfo.metaKey;
|
||||
};
|
||||
|
||||
})();
|
||||
|
@ -41,10 +41,7 @@ KeyboardWidget.prototype.render = function(parent,nextSibling) {
|
||||
domNode.className = classes.join(" ");
|
||||
// Add a keyboard event handler
|
||||
domNode.addEventListener("keydown",function (event) {
|
||||
if(event.keyCode === self.keyInfo.keyCode &&
|
||||
event.shiftKey === self.keyInfo.shiftKey &&
|
||||
event.altKey === self.keyInfo.altKey &&
|
||||
event.ctrlKey === self.keyInfo.ctrlKey) {
|
||||
if($tw.utils.checkKeyDescriptor(event,self.keyInfo)) {
|
||||
self.dispatchMessage(event);
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
Loading…
x
Reference in New Issue
Block a user