CodeLearner
CodeLearner

Reputation: 13

Javascript Assigning a keyboard shortcut to execute a function, my code isn't working, why?

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!

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 ();

}

Upvotes: 0

Views: 116

Answers (0)

Related Questions