Get started with mousetrap CDN

Apache-2.0 licensed

Mousetrap: Simple key event utility for Vue.js, React, Angular, JS.

Tags:
  • keyboard
  • shortcut
  • mouse

Stable version

Copied!

How to start using mousetrap CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with mousetrap CDN - cdnhub.io</title>
  <script src="https://cdn.cdnhub.io/mousetrap/1.6.5/mousetrap.min.js"></script>
</head>
<body>
  <button id="start">Start</button>
  <script>
    const shortcuts = {
      'ctrl+q': function() { alert('Ctrl+Q pressed'); },
      'alt+x': function() { alert('Alt+X pressed'); }
    };

    const setupShortcuts = () => {
      Mousetrap.bind(document, shortcuts);
    };

    const start = document.getElementById('start');
    start.addEventListener('click', () => {
      setupShortcuts();
    });
  </script>
</body>
</html>
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!
Copied!

All versions