Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
17 changes: 12 additions & 5 deletions jquery.shortcuts.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
/**
* JavaScript Shortcuts Library (jQuery plugin) v0.7
* JavaScript Shortcuts Library (jQuery plugin) v0.8
* http://www.stepanreznikov.com/js-shortcuts/
* Copyright (c) 2010 Stepan Reznikov (stepan.reznikov@gmail.com)
* Date: 2010-08-08
* Date: 2015-08-21
*/

/*global jQuery */

(function($) {

var browser = {
mozilla : /firefox/.test(navigator.userAgent.toLowerCase()),
webkit : /webkit/.test(navigator.userAgent.toLowerCase()),
opera : /opera/.test(navigator.userAgent.toLowerCase()),
msie : /msie/.test(navigator.userAgent.toLowerCase()),
}

/** Special keys */
var special = {
'backspace': 8,
Expand Down Expand Up @@ -41,8 +48,8 @@
'f11': 122,
'f12': 123,
'?': 191, // Question mark
'minus': $.browser.opera ? [109, 45] : $.browser.mozilla ? 109 : [189, 109],
'plus': $.browser.opera ? [61, 43] : $.browser.mozilla ? [61, 107] : [187, 107]
'minus': browser.opera ? [109, 45] : browser.mozilla ? 109 : [189, 109],
'plus': browser.opera ? [61, 43] : browser.mozilla ? [61, 107] : [187, 107]
};

/** Hash for shortcut lists */
Expand Down Expand Up @@ -142,7 +149,7 @@

if (isStarted) { return; } // We are going to attach event handlers only once, the first time this method is called.

$(document).bind(($.browser.opera ? 'keypress' : 'keydown') + '.shortcuts', function(e) {
$(document).bind((browser.opera ? 'keypress' : 'keydown') + '.shortcuts', function(e) {
// For a-z keydown and keyup the range is 65-90 and for keypress it's 97-122.
if (e.type === 'keypress' && e.which >= 97 && e.which <= 122) {
e.which = e.which - 32;
Expand Down
2 changes: 1 addition & 1 deletion jquery.shortcuts.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ <h1>JavaScript Shortcuts Library - Test page (hold)</h1>

<div id="footer"><p>Feedback: @ <a href="mailto:stepan.reznikov@gmail.com">Stepan Reznikov</a> | <a href="http://github.com/stepanvr/js-shortcuts">GitHub</a></p></div>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script type="text/javascript" src="jquery.shortcuts.min.js"></script>

<script type="text/javascript">
Expand Down