Get started with keypress CDN

Apache-2.0 licensed

Small JS library: Keypress - friendly keyboard event listener API.

Tags:
  • keypress

Stable version

Copied!

How to start using keypress CDN


<!DOCTYPE html>
<html>
<head>
  <title>Get started with keypress CDN - cdnhub.io</title>
  <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/keypress.min.js"></script>
  <script>
    document.addEventListener('DOMContentLoaded', () => {
      const input = document.querySelector('input');

      keypress(input, (event) => {
        if (event.keyCode === 13) {
          console.log('Enter key pressed');
        }
      });
    });
  </script>
  <style>
    input { width: 100%; padding: 10px; }
  </style>
</head>
<body>
  <input type="text" placeholder="Press Enter to log a message">
</body>
</html>
Copied!
Copied!
Copied!

All versions