d
Amit DhamuSoftware Engineer
 

Implement Keyboard Shortcuts For Your Website

1 minute read 00000 views
$(document).ready(function () {
  $(this).on('keyup', function (e) {
    if ($('input, textarea').is(':focus')) {
      return false
    } else {
      switch (e.keyCode) {
        case 65:
          // Do something here when I press the A key
          break
        case 69:
          // Do something here when I press the E key
          break
        // etc......
      }
    }
  })
})

For a list of JavaScript keycodes, you can visit this website.