Comparing version 0.3.1 to 0.3.2
/* | ||
* jwerty - Awesome handling of keyboard events | ||
* | ||
* enderBridge.js | ||
* 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 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. | ||
* | ||
* This code is licensed under the MIT | ||
* For more details, see http://www.opensource.org/licenses/mit-license.php | ||
* For more information, see http://github.com/keithcirkel/jwerty | ||
* For the full license see: http://keithamus.mit-license.org/ | ||
* For more information see: http://keithamus.github.com/jwerty | ||
* | ||
* @author Keith Cirkel ('keithamus') <jwerty@keithcirkel.co.uk> | ||
* @license http://www.opensource.org/licenses/mit-license.php | ||
* @license http://keithamus.mit-license.org/ | ||
* @copyright Copyright © 2011, Keith Cirkel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
@@ -36,0 +17,0 @@ (function ($, r) { |
/* | ||
* jwerty - Awesome handling of keyboard events | ||
* | ||
* 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 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. | ||
* | ||
* This code is licensed under the MIT | ||
* For more details, see http://www.opensource.org/licenses/mit-license.php | ||
* For more information, see http://github.com/keithcirkel/jwerty | ||
* For the full license see: http://keithamus.mit-license.org/ | ||
* For more information see: http://keithamus.github.com/jwerty | ||
* | ||
* @author Keith Cirkel ('keithamus') <jwerty@keithcirkel.co.uk> | ||
* @license http://www.opensource.org/licenses/mit-license.php | ||
* @license http://keithamus.mit-license.org/ | ||
* @copyright Copyright © 2011, Keith Cirkel | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
* | ||
*/ | ||
@@ -117,3 +100,3 @@ (function (global, exports) { | ||
// Delete key, on Mac: ⌫ (Delete) | ||
del: 45, 'delete': 45, | ||
del: 46, 'delete': 46, | ||
@@ -136,3 +119,4 @@ // Left Arrow Key, or ← | ||
'-': 109, subtract: 109, | ||
//';': 186, //??? | ||
// Semicolon | ||
';': 186, semicolon:186, | ||
// = or equals | ||
@@ -401,3 +385,3 @@ '=': 187, 'equals': 187, | ||
// ...except for jwertyCode.jwertyCombo... | ||
if (p !== 'jwertyCombo' && event[p] !== jwertyCode[n][p]) returnValue = false; | ||
if (p !== 'jwertyCombo' && event[p] != jwertyCode[n][p]) returnValue = false; | ||
} | ||
@@ -404,0 +388,0 @@ // If this jwertyCode optional wasn't falsey, then we can return early. |
{ | ||
"name": "jwerty", | ||
"version": "0.3.1", | ||
"description": "Awesome handling of keyboard events", | ||
"homepage": "http://keithamus.github.com/jwerty", | ||
"keywords": [ "key", "dom", "keyup", "KeyboardEvent", "addEventListener", "jQuery", "Zepto", "browser", "ender" ], | ||
"maintainers": [ | ||
{ | ||
"name": "Keith Cirkel", | ||
"email": "jwerty@keithcirkel.co.uk", | ||
"web": "http://keithcirkel.co.uk" | ||
} | ||
], | ||
"licenses": [ { "type": "MIT", "url": "http://www.opensource.org/licenses/mit-license.php" } ], | ||
"repositories": [ { "type": "git", "url": "https://github.com/keithamus/jwerty" } ], | ||
"main": "./jwerty.js", | ||
"ender": "./jwerty.enderBridge.js" | ||
"name": "jwerty", | ||
"version": "0.3.2", | ||
"description": "Awesome handling of keyboard events", | ||
"homepage": "http://keithamus.github.com/jwerty", | ||
"keywords": [ | ||
"key", | ||
"dom", | ||
"keyup", | ||
"KeyboardEvent", | ||
"addEventListener", | ||
"jQuery", | ||
"Zepto", | ||
"browser", | ||
"ender" | ||
], | ||
"maintainers": [ | ||
{ | ||
"name": "Keith Cirkel", | ||
"email": "jwerty@keithcirkel.co.uk", | ||
"web": "http://keithcirkel.co.uk" | ||
} | ||
], | ||
"licenses": [ | ||
{ | ||
"type": "MIT", | ||
"url": "http://www.opensource.org/licenses/mit-license.php" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "git", | ||
"url": "https://github.com/keithamus/jwerty" | ||
} | ||
], | ||
"main": "./jwerty.js", | ||
"ender": "./jwerty.enderBridge.js" | ||
} |
@@ -1,4 +0,5 @@ | ||
jwerty | ||
[jwerty](http://keithcirkel.co.uk/jwerty/) | ||
====== | ||
##### Awesome handling of keyboard events | ||
###### http://keithcirkel.co.uk/jwerty/ | ||
@@ -20,47 +21,69 @@ jwerty is a JS lib which allows you to bind, fire and assert key combination | ||
jwerty.key('ctrl+shift+P', function () { [...] }); | ||
jwerty.key('⌃+⇧+P', function () { [...] }); | ||
```javascript | ||
jwerty.key('ctrl+shift+P', function () { [...] }); | ||
jwerty.key('⌃+⇧+P', function () { [...] }); | ||
``` | ||
Specify optional keys... | ||
jwerty.key('⌃+⇧+P/⌘+⇧+P', function () { [...] }); | ||
```javascript | ||
jwerty.key('⌃+⇧+P/⌘+⇧+P', function () { [...] }); | ||
``` | ||
or key sequences. | ||
jwerty.key('↑,↑,↓,↓,←,→,←,→,B,A,↩', function () { [...] }); | ||
```javascript | ||
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 | ||
```javascript | ||
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); | ||
```javascript | ||
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'); | ||
```javascript | ||
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'); | ||
```javascript | ||
jwerty.key('⌃+⇧+P/⌘+⇧+P', function () { [...] }, this, 'input.email', '#myForm'); | ||
``` | ||
If you're bining to a selector, you can also ommit the function context: | ||
jwerty.key('⌃+⇧+P/⌘+⇧+P', function () { [...] }, 'input.email', '#myForm'); | ||
```javascript | ||
jwerty.key('⌃+⇧+P/⌘+⇧+P', function () { [...] }, 'input.email', '#myForm'); | ||
``` | ||
Use `jwerty.event` as a decorator, to bind events your own way: | ||
$('#myinput').bind('keydown', jwerty.event('⌃+⇧+P/⌘+⇧+P', function () { [...] })); | ||
```javascript | ||
$('#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) ) { | ||
[...] | ||
} | ||
```javascript | ||
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'); | ||
```javascript | ||
jwerty.fire('enter', 'input:first-child', '#myForm'); | ||
``` |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
166382
18
1298
88
0
2