jQuery key events for humans.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


jQuery Human Keyword Events

Tired of write meaningless code for key events?

$(..).keyup(function(e) {
  if (e.which == 27) {
    // code and more code

Worry no more!

$(..).bind('keyup:escape', function(e) {
    // code and more code

Using it


First, load jQuery and then the plugin:

<script src="jquery.min.js" type="text/javascript"></script>
<script src="jquery.human-keyword-events.js" type="text/javascript"></script>

Binding events

Binding a event to escape keyup

$(...).bind('keyup:escape', fn)

Binding a event to enter keydown

$(...).bind('keydown:enter', fn)

Unbinding events

Unbinding a event to enter keydown


Unbinding a event to enter keydown


Use it with Backbone.js!

var View = Backbone.View.extend({

  events: {
    "keyup:escape":           "closeModals",
    "keyup:enter textarea":   "save",
    "keydown:s":              "save"


Keys supported:

  • escape
  • enter
  • shift
  • control
  • alt
  • space
  • tab
  • left
  • up
  • right
  • down
  • a .. z
  • 0 .. 9

Managing your own key events

Want to add your own keys?

jQuery.eventKeys['esc'] = 27;

Want to use them?

$(...).bind('keyup:esc', fn)


Tested with jQuery 1.8.3, more and better testing coming!