问题描述
链接到我的笔:https://codepen.io/dev999/pen/pPdOGW链接到我的应用程序。我是初学者,这是我第一次使用库和基本的DOM操作。我想为我的待办事项列表中的每个操作分配键盘快捷键。有人可以帮我解决这个问题吗?谢谢!
我尝试过:
我用过的东西:
链接到Mousetrap库:cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/mousetrap.js
链接到图书馆的解释:https://craig.is/killing/mice
//尝试将键盘//快捷键ctrl + q分配给操作//addTodo()。 //使用Mousetrap库
Mousetrap.bind('ctrl + q',function(e){
addTodo;
});
function addTodo(){
todo.push(prompt(输入一个你要添加到待办事项中的项目!));
dispTodo();
}
Link to my pen: https://codepen.io/dev999/pen/pPdOGW Link to my to do app. I'm a beginner, this is my first time using a library and basic DOM manipulation. I'd like to assign keyboard shortcuts to each action in my to do list. Could someone please help me out with this? Thank you!
What I have tried:
Stuff I used:
Link to Mousetrap library: cdnjs.cloudflare.com/ajax/libs/mousetrap/1.6.1/mousetrap.js
Link to the explanations for the library: https://craig.is/killing/mice
// Trying to assign the keyboard //shortcut ctrl+q to the action //"addTodo()". //Using Mousetrap library Mousetrap.bind('ctrl+q', function(e) { addTodo; }); function addTodo () { todo.push(prompt ("Enter one item you want to add to your todo!")); dispTodo (); }
这篇关于使用mousetrap库单击带键盘快捷键的按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!