Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Fix simple typo, omited -> omitted #61

Open
wants to merge 85 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
0042fad
Update jQuery to version 1.4.2.
jeresig Feb 22, 2010
0451de1
jQuery Hotkeys rewritten to work with jQuery 1.4.2. A bunch of old co…
jeresig Feb 23, 2010
a1bd243
Included password and HTML5 input types in default ignore list
kevingorski Nov 26, 2010
a63c714
Updated the link to Tzury's hotkeys instead of a 404.
Jun 21, 2011
2fa06e2
Update - foreach for bind!
tutkun Sep 20, 2012
d73131d
Add in jQuery plugin manifest.
jeresig Jan 17, 2013
0033d90
Merge pull request #2 from kevingorski/master
jeresig Feb 11, 2013
657710d
One small change is: now keys are passed by object { keys: '...' }
Mar 17, 2013
90bf64c
Backward compatibility
Mar 17, 2013
dacd92f
Updated hotKey README with an example using jQuery's on & off methods
vasilionjea Mar 18, 2013
189baa3
added three special keys: ; ' \
gabrielflorit Mar 31, 2013
549178d
Merge pull request #20 from gabrielflorit/master
jeresig Apr 23, 2013
a4b5690
Merge pull request #18 from vasilionjea/master
jeresig Apr 23, 2013
748bffb
Merge pull request #19 from deMoneIrk/master
jeresig Apr 23, 2013
5f23d79
Merge pull request #15 from tutkun/patch-1
jeresig Apr 23, 2013
a363591
fix bugs.
CalvinChen May 1, 2013
18ec561
add keyCode 10 for return
YuppY May 12, 2013
aef1b64
Merge pull request #23 from CalvinChen/master
tbranyen May 25, 2013
c52aae2
small syntax fix
msantic May 1, 2013
c34e74c
Merge pull request #5 from skoczen/patch-1
tbranyen May 25, 2013
f8225d1
added in grunt for linting, eventually testing
tbranyen May 25, 2013
2fdc8c1
added tel input type
tbranyen May 25, 2013
404d37c
Merge pull request #30 from YuppY/add-return-special-code
tbranyen May 25, 2013
4ac39a7
Removed unused variable key per @YuppY, updated the jQuery reference …
tbranyen May 25, 2013
8b73fdc
fix keypress on special keys and other events on characters
YuppY May 12, 2013
7dfe654
Merge pull request #28 from YuppY/fix-special-keypress
tbranyen Jun 2, 2013
3cae520
restore keyup/keydown for character keys
YuppY Jun 9, 2013
87639b5
minor edit
nicoder Oct 11, 2013
8b67445
Merge pull request #31 from YuppY/fix-special-keypress
tbranyen Feb 2, 2014
cff06ff
Merge pull request #35 from nicoder/patch-1
tbranyen Feb 2, 2014
599bff2
Adding Grunt with jasmine + jshint tasks and some basic tests, update…
rpocklin Feb 2, 2014
921ccb1
Merge pull request #36 from rpocklin/master
rpocklin Feb 4, 2014
42a2334
Renamed travis.yml to correct name for travis-CI.
rpocklin Feb 4, 2014
04e4317
Touched Gruntfile.js to trigger initial travis build.
rpocklin Feb 5, 2014
d971a5a
Updated travis dependencies and build task.
rpocklin Feb 5, 2014
74d6882
Getting grunt to run in Travis-CI Environment.
rpocklin Feb 5, 2014
1a3ca48
Added more jasmine tests, grunt watch task and updated README.
rpocklin Feb 11, 2014
d078652
Updated link in README.
rpocklin Feb 11, 2014
3b37b7c
Reviewed 'meta' key functionality for Mac and added 'hyper' keyboard …
rpocklin Feb 23, 2014
4dbba5c
Merge pull request #37 from rpocklin/master
rpocklin Mar 25, 2014
f42f117
Reviewed 'meta' key functionality for Mac and added 'hyper' keyboard …
rpocklin Feb 20, 2014
111eeab
Added ability to override hotkey ignoring on text input field types.
rpocklin Apr 1, 2014
c6d8584
Added syntax highlighting
markijbema Jun 5, 2014
b78bf04
Merge pull request #38 from rpocklin/master
rpocklin Jun 30, 2014
4968f2f
Merge pull request #39 from markijbema/patch-1
rpocklin Jun 30, 2014
7f6a925
Update jquery.hotkeys.js
Jul 18, 2014
cf24c91
Adding grunt-jsbeautify.
rpocklin Aug 11, 2014
58ee2b7
Re-formatting files using js-beautify.
rpocklin Aug 12, 2014
c245b70
Merge pull request #43 from rpocklin/beautify-js
rpocklin Aug 14, 2014
26c02d0
Fixing keypress binding issue introduced in 8b73fdc and 3cae520.
rpocklin Aug 19, 2014
8f3d041
Updated key binding specs and added namespaced unbind specs.
rpocklin Aug 19, 2014
a282dc3
Updated README.md example link to use rawgit.com (previous link not l…
rpocklin Aug 19, 2014
7bff0f9
Fixing case where metaKey is triggered when ctrlKey pressed.
rpocklin Aug 19, 2014
950ece8
Added test case for ctrl key binding.
rpocklin Aug 19, 2014
b5eb650
Merge pull request #44 from rpocklin/master
rpocklin Aug 19, 2014
f011f8c
Update dependencies, add missing grunt-contrib-watch dependency
lazd Aug 20, 2014
5183bff
make this module check for jQuery on window if it's not in this
morgante Aug 20, 2014
fe57ca9
Merge pull request #46 from lazd/gruntfix
rpocklin Aug 21, 2014
035bdd8
hint to jshint that this module is for the browser
morgante Aug 26, 2014
d8d4644
first check for global reference to jQuery, for Browserified jQuery c…
morgante Aug 27, 2014
e31dd86
Merge remote-tracking branch 'upstream/master' into browserify
morgante Aug 27, 2014
7283097
include brief remarks on browserify in README
morgante Aug 27, 2014
48c8367
Merge pull request #49 from morgante/browserify
rpocklin Sep 11, 2014
ba8ee30
Added bower.json file
lipis Sep 18, 2014
06b796c
Added more into ignore list
lipis Sep 30, 2014
7962f16
Merge pull request #50 from lipis/patch-1
rpocklin Sep 30, 2014
1b360b4
Updated bower.json (mainly from hotkeys.jquery.json)
rpocklin Sep 30, 2014
a63c980
Tweaking ignore on bower.json
rpocklin Sep 30, 2014
f2d7bfa
Beautifying jquery.hotkeys.js
rpocklin Oct 17, 2014
05a1370
Added bower_components to .gitignore
rpocklin Oct 17, 2014
9164e50
Update jquery.hotkeys.js
abolishme Jan 7, 2015
46b23fb
Merge pull request #54 from abolishme/patch-1
rpocklin Jan 13, 2015
efee6d4
Added test for not binding to input[search] unless done explicitly.
rpocklin Jan 13, 2015
0e700f8
Enable default input types only to be bound directly to be configurable.
rpocklin Jan 13, 2015
a4cdf9f
Excluded `contenteditable` fields by default and added to specs.
rpocklin Jan 13, 2015
8be4462
Added flag to control enable / disable of direct element binding #51.
rpocklin Jan 13, 2015
818081b
Updated README.md in line with new input configuration options.
rpocklin Jan 13, 2015
346f110
Merge pull request #41 from paladox/patch-1
rpocklin Mar 27, 2015
0d75b79
Update README.md
revolter May 21, 2015
457690b
Merge pull request #56 from revolter/patch-1
tbranyen May 21, 2015
58038e6
Fixed version number
Nov 8, 2015
1ec07a6
Merge pull request #57 from RandomlyKnighted/master
rpocklin Nov 8, 2015
c1907c0
Fixed version number from 0.1.0 to 0.2.0
swcheon Dec 5, 2015
f24f1da
Merge pull request #58 from swcheon/master
rpocklin Sep 19, 2016
b8aa610
docs: Fix simple typo, omited -> omitted
timgates42 Sep 7, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
.idea
.grunt
bower_components
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
node_js:
- "0.10"
before_script:
- npm install -g grunt-cli
73 changes: 73 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
module.exports = function(grunt) {

// Configuration.
grunt.initConfig({
// verifies we have formatted our js and HTML according to our style conventions
jsbeautifier: {
files: ['Gruntfile.js', 'jquery.hotkeys.js', 'test/spec/**/*.js'],
options: {
mode: 'VERIFY_ONLY',
js: {
'indent_size': 2,
'indent_char': ' ',
'indent_level': 0,
'indent_with_tabs': false,
'preserve_newlines': true,
'max_preserve_newlines': 2,
'jslint_happy': false,
'brace_style': 'end-expand',
'indent_scripts ': 'keep',
'keep_array_indentation': true,
'keep_function_indentation': false,
'space_before_conditional': true,
'break_chained_methods': false,
'eval_code': false,
'unescape_strings': false,
'wrap_line_length': 0
}
}
},
jshint: {
options: {
"undef": true,
"unused": true
},
files: 'jquery.hotkeys.js'
},
jasmine: {
pivotal: {
options: {
vendor: ['jquery-1.4.2.js', 'jquery.hotkeys.js', 'test/lib/**.js'],
outfile: 'test/SpecRunner.html',
keepRunner: true,
specs: 'test/spec/*Spec.js'
}
}
},
watch: {
scripts: {
files: ['**/*.js'],
tasks: ['default'],
options: {
spawn: false,
interrupt: true,
debounceDelay: 1000
}
}
}
});

grunt.loadNpmTasks('grunt-contrib-watch');

// Beautify javascript
grunt.loadNpmTasks("grunt-jsbeautifier");

// Task loading
grunt.loadNpmTasks("grunt-contrib-jshint");

// Running tests
grunt.loadNpmTasks('grunt-contrib-jasmine');

// Task registration.
grunt.registerTask("default", ["jsbeautifier", "jshint", "jasmine"]);
};
138 changes: 80 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,93 +1,115 @@
# jQuery.Hotkeys [![Build Status](https://secure.travis-ci.org/jeresig/jquery.hotkeys.png)](http://travis-ci.org/jeresig/jquery.hotkeys)

#About
**jQuery.hotkeys** is a plug-in that lets you easily add and remove handlers for keyboard events anywhere in your code supporting almost any key combination.
**jQuery Hotkeys** is a plug-in that lets you easily add and remove handlers for keyboard events anywhere in your code supporting almost any key combination.

It is based on a library [Shortcut.js](http://www.openjs.com/scripts/events/keyboard_shortcuts/shortcut.js) written by [Binny V A](http://www.openjs.com/).
This plugin is based off of the plugin by Tzury Bar Yochay: [jQuery.hotkeys](https://github.com/tzuryby/jquery.hotkeys)

The syntax is as follows:
<pre>
$(expression).bind(<types>,<options>, <handler>);
$(expression).unbind(<types>,<options>, <handler>);

$(document).bind('keydown', 'Ctrl+a', fn);
```javascript
$(expression).bind(types, keys, handler);
$(expression).unbind(types, handler);

$(document).bind('keydown', 'ctrl+a', fn);

// e.g. replace '$' sign with 'EUR'
$('input.foo').bind('keyup', '$', function(){
this.value = this.value.replace('$', 'EUR');
this.value = this.value.replace('$', 'EUR');
});
```

$('div.foo').unbind('keydown', 'Ctrl+a', fn);
</pre>
## [Live Demo](http://jshotkeys.googlepages.com/test-static-01.html)
Syntax when wanting to use jQuery's `on()`/`off` methods:

## Types
Supported types are `'keydown'`, `'keyup'` and `'keypress'`
```javascript
$(expression).on(types, null, keys, handler);
$(expression).off(types, handler);

## Options
The options are `'combi'` i.e. the key combination, and `'disableInInput'` which allow your code not to be executed when the cursor is located inside an input ( `$(elem).is('input') || $(elem).is('textarea')` ).
$(document).on('keydown', null, 'ctrl+a', fn);

As you can see, the key combination can be passed as string or as an object. You may pass an object in case you wish to override the default option for `disableInInput` which is set to `false`:
<pre>
$(document).bind('keydown', {combi:'a', disableinInput: true}, fn);
</pre>
I.e. when cursor is within an input field, `'a'` will be inserted into the input field without interfering.
// e.g. replace '$' sign with 'EUR'
$('input.foo').on('keyup', null, '$', function(){
this.value = this.value.replace('$', 'EUR');
});
```

If you want to use more than one modifiers (e.g. alt+ctrl+z) you should define them by an alphabetical order e.g. alt+ctrl+shift
## Example

Modifiers are case insensitive, i.e. 'Ctrl+a' 'ctrl+a'.
[Example](https://rawgit.com/jeresig/jquery.hotkeys/master/test-static-01.html)

## Handler
In previous versions there was an option propagate which is removed now and implemented at the user code level.
## Event Types

When using jQuery, if an event handler returns false, jQuery will call `stopPropagation()` and `preventDefault()`
Supported types are `'keydown'`, `'keyup'` and `'keypress'`

## jQuery Compatibility
Tested with *jQuery 1.2.6*

It known to be working with all the major browsers on all available platforms (Win/Mac/Linux)
Works with jQuery 1.4.2 and newer.

It is known to be working with all the major browsers on all available platforms (Win/Mac/Linux)

* IE 6/7/8+
* FF 1.5/2/3+
* Opera-9+
* Safari-3+
* Chrome-0.2+

## Browserify Compatibility
If you want to include this module in a Browserified project, just add it to node_modules and require it.
```javascript
require('jquery.javascript');
```

This will work if jQuery is global (ex. served from a CDN). If it's not, you need to [shim it](https://github.com/thlorenz/browserify-shim#a-expose-global-variables-via-global):
```javascript
{
"browserify-shim": {
"jquery": "global:jQuery"
}
}
```

* IE 6/7/8
* FF 1.5/2/3
* Opera-9
* Safari-3
* Chrome-0.2
## Notes

## Features added in this version (0.7.x)
* Implemented as $.fn - let you use `this`.
* jQuery selectors are supported.
* Extending `$.fn.bind` and `$.fn.unbind` so you get a single interface for binding events to handlers

## Overriding jQuery
The plugin wraps the following jQuery methods:
* $.fn.bind
* $.fn.unbind
* $.find
Modifiers are not case sensitive (`Ctrl` == `ctrl` == `cTRL`)

Even though the plugin overrides these methods, the original methods will *always* be called.
If you want to use more than one modifier (e.g. `alt+ctrl+z`) you should define them by an alphabetical order e.g. alt+ctrl+shift

The plugin will add functionality only for the `keydown`, `keyup` and `keypress` event types. Any other types are passed untouched to the original `'bind()'` and `'unbind()'` methods.
Hotkeys aren't tracked if you're inside of an input element (unless you explicitly bind the hotkey directly to the input). This helps to avoid conflict with normal user typing.

Moreover, if you call `bind()` without passing the shortcut key combination e.g. `$(document).bind('keydown', fn)` only the original `'bind()'` method will be executed.
You can use namespacing by adding a suffix to the event type (e.g. `keyup.toggle`)

I also modified the `$.fn.find` method by adding a single line at the top of the function body. here is the code:

<pre>
jQuery.fn.find = function( selector ) {
// the line I added
this.query=selector;
// call jQuery original find
return jQuery.fn.__find__.apply(this, arguments);
};
</pre>
## Hotkeys within inputs

You can read about this at [jQuery's User Group](http://groups.google.com/group/jquery-en/browse_thread/thread/18f9825e8d22f18d)
Hotkeys aren't tracked if the user is focused within an input element or any element that has `contenteditable="true"` unless you bind the hotkey directly to the element. This helps to avoid conflict with normal user typing.
If you don't want this, you can change the booleans of the following to suit:

###Notes
* `jQuery.hotkeys.options.filterInputAcceptingElements`
* `jQuery.hotkeys.options.filterContentEditable`
* `jQuery.hotkeys.options.filterTextInputs` (deprecated, will be removed in a later version)

### Meta and Hyper Keys
Meta and hyper keys don't register on `keyup` in any browser tested.

#### Chrome 33.0.1750.117
Meta key registers on `keydown` event.
Hyper key registers on `keydown` event.

#### Firefox 27.0.1 and Safari 7.0.1
Meta key registers on `keydown` and `keypress` events.
Hyper key registers on `keydown` and `keypress` events.

#### Opera 19.0
Meta key doesn't register at all :(
Hyper key registers on `keydown` and `keypress` events.

#### TL;DR
Bind to `keydown` event for meta and hyper keys, but meta key does not work in Opera ;)

### Addendum

Firefox is the most liberal one in the manner of letting you capture all short-cuts even those that are built-in in the browser such as `Ctrl-t` for new tab, or `Ctrl-a` for selecting all text. You can always bubble them up to the browser by returning `true` in your handler.

Others, (IE) either let you handle built-in short-cuts, but will add their functionality after your code has executed. Or (Opera/Safari) will *not* pass those events to the DOM at all.

*So, if you bind `Ctrl-Q` or `Alt-F4` and your Safari/Opera window is closed don't be surprised.*


###Current Version is: beta 0.7
21 changes: 21 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "jquery.hotkeys",
"description": "jQuery Hotkeys lets you watch for keyboard events anywhere in your code supporting almost any key combination.",
"homepage": "http://github.com/jeresig/jquery.hotkeys",
"repository": "git://github.com/jeresig/jquery.hotkeys.git",
"keywords": ["jquery", "hotkeys", "keyboard", "events", "key", "bindings"],
"authors": ["John Resig <[email protected]> (http://ejohn.org)"],
"main": "jquery.hotkeys.js",
"ignore": [
"jquery-*",
"test*",
"*.yml",
".gitignore",
"Gruntfile.js",
"*.json"
],
"dependencies": {
"jquery": ">= 1.4.2"
},
"license": ["MIT", "GPL-2.0"]
}
36 changes: 36 additions & 0 deletions hotkeys.jquery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "hotkeys",
"title": "jQuery Hotkeys",
"description": "jQuery Hotkeys lets you watch for keyboard events anywhere in your code supporting almost any key combination.",
"keywords": [
"keyboard",
"events"
],
"version": "0.2.0",
"author": {
"name": "John Resig",
"url": "https://ejohn.org/"
},
"maintainers": [
{
"name": "John Resig",
"email": "[email protected]",
"url": "http://ejohn.org/"
}
],
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
},
{
"type": "GPLv2",
"url": "http://www.gnu.org/licenses/gpl-2.0.html"
}
],
"homepage": "https://github.com/jeresig/jquery.hotkeys",
"docs": "https://github.com/jeresig/jquery.hotkeys",
"dependencies": {
"jquery": ">=1.4.2"
}
}
Loading