本文整理匯總了TypeScript中mousetrap.bindGlobal函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript bindGlobal函數的具體用法?TypeScript bindGlobal怎麽用?TypeScript bindGlobal使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了bindGlobal函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createKeyBinding
function createKeyBinding(name, description, preventDefault, pressAction) {
var keyBinding = parseKeyBinding(name);
// var editor = ace.edit("editor");
//
// console.log(keyBinding.editor);
// editor.commands.addCommand({
// name : name,
// bindKey : {
// win : keyBinding.editor,
// mac : keyBinding.editor
// },
// exec : function(editor) {
// if(pressAction) {
// pressAction();
// }
// }
// });
keyBindings[keyBinding.editor] = Common.escapeHtml(description);
FileEditor.addEditorKeyBinding(keyBinding, pressAction);
Mousetrap.bindGlobal(keyBinding.global, function(e) {
if(pressAction) {
pressAction();
}
return !preventDefault;
});
}
示例2: function
commandRegistry.forEach(c=> {
if (c.config.context == CommandContext.Global
&& c.config.keyboardShortcut) {
Mousetrap.bindGlobal(c.config.keyboardShortcut, function() {
c.emit({});
return !!c.config.allowDefault;
});
}
});
示例3: createKeyUpBinding
function createKeyUpBinding(name, preventDefault, pressAction) {
var keyBinding = parseKeyBinding(name);
Mousetrap.bindGlobal(keyBinding.global, function(e) {
if(pressAction) {
pressAction();
}
return !preventDefault;
}, 'keyup');
}
示例4: register
export function register() {
commandRegistry.forEach(c=> {
if (c.config.context == CommandContext.Global
&& c.config.keyboardShortcut) {
Mousetrap.bindGlobal(c.config.keyboardShortcut, function() {
c.emit({});
return !!c.config.allowDefault;
});
}
});
// Commands with multiple key bindings
// enable at some point
Mousetrap.bindGlobal('mod+h', function() { // atom,sublime,c9
findAndReplace.emit({});
return false;
});
}