Skip to content

Commit

Permalink
Fixed fancyapps#32 - ignore key combinations
Browse files Browse the repository at this point in the history
  • Loading branch information
fancyapps committed Dec 1, 2011
1 parent f871790 commit 3ae3ef5
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions source/jquery.fancybox.js
Expand Up @@ -394,22 +394,24 @@

if (keys) {
D.bind('keydown.fb', function (e) {
// Ignore key events within form elements
if ($.inArray(e.target.tagName.toLowerCase(), ['input', 'textarea', 'select', 'button']) > -1) {
return;
}
var code;

if ($.inArray(e.keyCode, keys.close) > -1) {
F.close();
e.preventDefault();
// Ignore key combinations and key events within form elements
if (!e.ctrlKey && !e.altKey && !e.shiftKey && !e.metaKey && $.inArray(e.target.tagName.toLowerCase(), ['input', 'textarea', 'select', 'button']) < 0) {
code = e.keyCode;

} else if ($.inArray(e.keyCode, keys.next) > -1) {
F.next();
e.preventDefault();
if ($.inArray(code, keys.close) > -1) {
F.close();
e.preventDefault();

} else if ($.inArray(e.keyCode, keys.prev) > -1) {
F.prev();
e.preventDefault();
} else if ($.inArray(code, keys.next) > -1) {
F.next();
e.preventDefault();

} else if ($.inArray(code, keys.prev) > -1) {
F.prev();
e.preventDefault();
}
}
});
}
Expand Down

0 comments on commit 3ae3ef5

Please sign in to comment.