• This repository has been archived on 08/Nov/2017
  • Stars
    star
    1,213
  • Rank 36,995 (Top 0.8 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 12 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

โŒจ Awesome handling of keyboard events

No Longer Actively Maintained

If someone would like to take over maintainence, feel free to get in touch (@keithamus on twitter). I'll happily transfer this over.

Awesome handling of keyboard events

Gitter

NPM Downloads Release Gittip donate button

Sponsor

jwerty is a JS lib which allows you to bind, fire and assert key combination strings against elements and events. It normalises the poor std api into something easy to use and clear.

jwerty is a small library, weighing in at around 1.5kb bytes minified and gzipped (~3kb minified). jwerty has no dependencies, but is compatible with jQuery, Zepto, Ender or CanJS if you include those packages alongside it. You can install jwerty via npm (for use with Ender) or Bower.

For detailed docs, please read the README-DETAILED.md file.

The Short version

Use jwerty.key to bind your callback to a key combo (global shortcuts)

jwerty.key('ctrl+shift+P', function () { [...] });
jwerty.key('โŒƒ+โ‡ง+P', function () { [...] });

Specify optional keys:

jwerty.key('โŒƒ+โ‡ง+P/โŒ˜+โ‡ง+P', function () { [...] });

or key sequences:

jwerty.key('โ†‘,โ†‘,โ†“,โ†“,โ†,โ†’,โ†,โ†’,B,A,โ†ฉ', function () { [...] });

You can also (since 0.3) specify regex-like ranges:

jwerty.key('ctrl+[a-c]', function () { [...] }); // fires for ctrl+a,ctrl+b or ctrl+c

Pass in a context to bind your callback:

jwerty.key('โŒƒ+โ‡ง+P/โŒ˜+โ‡ง+P', function () { [...] }, this);

Pass in a selector to bind a shortcut local to that element:

jwerty.key('โŒƒ+โ‡ง+P/โŒ˜+โ‡ง+P', function () { [...] }, this, '#myinput');

Pass in a selector's context, similar to jQuery's $('selector', 'scope'):

jwerty.key('โŒƒ+โ‡ง+P/โŒ˜+โ‡ง+P', function () { [...] }, this, 'input.email', '#myForm');

If you're binding to a selector and don't need the context, you can ommit it:

jwerty.key('โŒƒ+โ‡ง+P/โŒ˜+โ‡ง+P', function () { [...] }, 'input.email', '#myForm');

Calls to jwerty.key return a subscription handle that you can use to disconnect the callback

var h = jwerty.key('ctrl+shift+P', function () { [...] })
h.unbind()

Use jwerty.event as a decorator, to bind events your own way:

$('#myinput').bind('keydown', jwerty.event('โŒƒ+โ‡ง+P/โŒ˜+โ‡ง+P', function () { [...] }));

Use jwerty.is to check a keyCombo against a keyboard event:

function (event) {
    if ( jwerty.is('โŒƒ+โ‡ง+P', event) ) {
        [...]
    }
}

Or use jwerty.fire to send keyboard events to other places:

jwerty.fire('enter', 'input:first-child', '#myForm');

More Repositories

1

npm-scripts-example

An example of how to use NPM scripts over Grunt/Gulp & Friends. http://blog.keithcirkel.co.uk/how-to-use-npm-as-a-build-tool
JavaScript
831
star
2

sort-package-json

Sort an Object or package.json based on the well-known package.json keys
JavaScript
712
star
3

hashmark

Take contents of a file (or stdin), and output as new file with a hash in the name
JavaScript
195
star
4

tempus

Tempus - Time for a new Date()
JavaScript
94
star
5

R.js

Internationalisation Library for Javascript
JavaScript
75
star
6

ecmascript-operator-overloading-proposal

A proposal for operator overloading in ECMAScript
64
star
7

proposal-object-freeze-seal-syntax

A JavaScript TC39 proposal for Object.freeze & Object.seal syntax
59
star
8

load-testing-node

Various setups for Load Balancing multiple Node.js processes on a single VM
Ruby
57
star
9

hbs-cli

A CLI for handlebars
JavaScript
43
star
10

csslex

A very small and very fast spec compliant css lexer
JavaScript
39
star
11

LinkyPass

LinkyPass Google Chrome Extension
JavaScript
36
star
12

invokers-polyfill

JavaScript
30
star
13

eslint-plugin-escompat

Report errors for code which wont work in browsers without transpiling
JavaScript
30
star
14

proxy-fluent-api

Make Fluent APIs using ES6 Proxies
JavaScript
28
star
15

sort-object-keys

Sort an object's keys, including an optional key list
JavaScript
28
star
16

gnome-shell-duckduckgo-search-provider

This is a Search Provider for Gnome Shell, and it provides DuckDuckGo Search functionality.
TypeScript
25
star
17

eslint-config-strict

ESLint sharable config for strict linting
JavaScript
25
star
18

postcss-hash

PostCSS plugin to replace output file names with HASH algorithms (md5, sha256, sha512, etc) and string length of your choice - for cache busting
JavaScript
24
star
19

reading-list

These are the books Im going to read
22
star
20

mini-observable

A mini implementation of TC39 observables, plus some utils!
TypeScript
22
star
21

WebCumberNode

JavaScript
20
star
22

proxy-method-missing

JavaScript
19
star
23

hdx

Refreshing CSS
CSS
16
star
24

rollup-plugin-brotli

JavaScript
15
star
25

nibstate

TypeScript
14
star
26

getbrightness

JavaScript
14
star
27

travis-ci-node-and-browser-qunit

JavaScript
13
star
28

alfred-docker-wizard

Control Docker machines & containers with Alfred
Shell
11
star
29

dotfiles

โšซ These are my dotfiles. There are many like it but these are mine.
Lua
10
star
30

deno-protod

TypeScript
9
star
31

proxy-object-observe

An Object.observe inspired util, based on ES6 proxies
JavaScript
7
star
32

proposal-array-compact

A proposal for adding a `compact()` method to Arrays
HTML
6
star
33

custom-attributes

TypeScript
6
star
34

Avalanche

A web-based GUI for torrent applications (such as rTorrent)
JavaScript
6
star
35

rollup-plugin-inline-invariant

JavaScript
6
star
36

GitAttributesTest

Showing how gitattributes can help you maintain a config file while keeping your config secrets from commits
Shell
5
star
37

deno-varint

Encode/Decode Number/BigInts into an array of Varint bytes
TypeScript
5
star
38

stylelint-config-strict

Stylelint sharable config for strict linting
JavaScript
5
star
39

mqtt-bridges

A platform for bridging APIs into mqtt messages
JavaScript
4
star
40

sourcemap-visualiser

JavaScript
4
star
41

cv

๐Ÿ“„ My curriculum vitae
HTML
3
star
42

wsb

JavaScript
3
star
43

sinomocha

Sinon.JS integration for the Mocha test harness
JavaScript
3
star
44

k-router

A MVC/MVT style router for Connect/Express apps
JavaScript
3
star
45

hubot-seriouslyguys

A hubot script for showing a 'Srsly Guise' gif when someone says 'Seriously Guys' or 'Srsly Guise'
CoffeeScript
3
star
46

probot-flood

A bot that automatically locks issues if they get flooded with comments
JavaScript
3
star
47

proposal-array-filtermap

A proposal for adding a `filterMap()` method to Arrays
HTML
3
star
48

deno-protoc-parser

Parse Google Protocol Buffer DSL into an AST, which can be converted into JSON or back into the Protocol Buffer DSL.
TypeScript
2
star
49

NobleClass

A JavaScript ES5 compliant Class implementation for Browser and NodeJS
JavaScript
2
star
50

zero-env

JavaScript
2
star
51

function-guard

JavaScript
2
star
52

tempus-js.com

Website for Tempus (https://github.com/tempusjs/tempus)
HTML
2
star
53

grunt-hooks

SCM Hook management for Grunt
JavaScript
2
star
54

parse-packagejson-name

Parse an npm package name and returns some mildly interesting details about it
JavaScript
2
star
55

hubot-soon

A hubot script for showing a 'SOON' image when someone says 'soon'
CoffeeScript
2
star
56

deno-scanner

Take a Deno.Reader and perform Lexical Analysis/Tokenization on it, returning a stream of tokens.
TypeScript
2
star
57

qunit-logging

JavaScript
1
star
58

proxy-hide-properties

Hide a property from all conceivable ways of being detected
JavaScript
1
star
59

radon-css

Lightweight alternative to Radium for React
JavaScript
1
star
60

eslint-config-strict-react

eslint-config-strict for React
JavaScript
1
star
61

tar-grab-unpack

Node.js utlity to grab tar files and unpack them
JavaScript
1
star
62

keithamus

1
star
63

evening-with-tc39

JavaScript
1
star
64

recipes

HTML
1
star
65

proposal-multi-module-files

A JavaScript TC39 Proposal for expressing multiple ES6 modules in a single file
JavaScript
1
star
66

vimstart

specify custom VIM start screen text using custom shell scripts
Vim Script
1
star