Skip to content

Commit 7946031

Browse files
committed
Use keydown instead of keypress to allow e.preventDefault()
1 parent a7afedb commit 7946031

5 files changed

Lines changed: 18 additions & 18 deletions

File tree

dist/ctrly.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
(function (global, factory) {
77
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
88
typeof define === 'function' && define.amd ? define(factory) :
9-
(global.ctrly = factory());
10-
}(this, (function () { 'use strict';
9+
(global = global || self, global.ctrly = factory());
10+
}(this, function () { 'use strict';
1111

1212
function activeElement() {
1313
try {
@@ -549,7 +549,7 @@
549549
}
550550
}
551551
var removeControlClick;
552-
var removeControlKeypress;
552+
var removeControlKeydown;
553553
function init() {
554554
if (!removeControlClick) {
555555
removeControlClick = delegate(document, 'click', controlSelector, function (e, control) {
@@ -558,7 +558,7 @@
558558
toggle(e, control);
559559
}
560560
});
561-
removeControlKeypress = delegate(document, 'keypress', controlSelector, function (e, control) {
561+
removeControlKeydown = delegate(document, 'keydown', controlSelector, function (e, control) {
562562
if (keyCode(e) === 13
563563
|| keyCode(e) === 32
564564
) {
@@ -607,8 +607,8 @@
607607
if (fullReset && removeControlClick) {
608608
removeControlClick();
609609
removeControlClick = null;
610-
removeControlKeypress();
611-
removeControlKeypress = null;
610+
removeControlKeydown();
611+
removeControlKeydown = null;
612612
}
613613
find(controlSelector).forEach(function (control) {
614614
if (fullReset) {
@@ -647,4 +647,4 @@
647647

648648
return ctrly;
649649

650-
})));
650+
}));

dist/ctrly.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/ctrly.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ function ctrly() {
543543
}
544544
}
545545
var removeControlClick;
546-
var removeControlKeypress;
546+
var removeControlKeydown;
547547
function init() {
548548
if (!removeControlClick) {
549549
removeControlClick = delegate(document, 'click', controlSelector, function (e, control) {
@@ -552,7 +552,7 @@ function ctrly() {
552552
toggle(e, control);
553553
}
554554
});
555-
removeControlKeypress = delegate(document, 'keypress', controlSelector, function (e, control) {
555+
removeControlKeydown = delegate(document, 'keydown', controlSelector, function (e, control) {
556556
if (keyCode(e) === 13
557557
|| keyCode(e) === 32
558558
) {
@@ -601,8 +601,8 @@ function ctrly() {
601601
if (fullReset && removeControlClick) {
602602
removeControlClick();
603603
removeControlClick = null;
604-
removeControlKeypress();
605-
removeControlKeypress = null;
604+
removeControlKeydown();
605+
removeControlKeydown = null;
606606
}
607607
find(controlSelector).forEach(function (control) {
608608
if (fullReset) {

0 commit comments

Comments
 (0)