Skip to content

Commit

Permalink
Close modal on keydown instead of keyup (solves vodkabears#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
vodkabears committed Jul 10, 2015
1 parent 78b9432 commit 74e21c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/remodal.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,8 +739,8 @@
$container[PLUGIN_NAME](options);
});

// Handles the keyup event
$(document).on('keyup.' + NAMESPACE, function(e) {
// Handles the keydown event
$(document).on('keydown.' + NAMESPACE, function(e) {
if (current && current.settings.closeOnEscape && current.state === STATES.OPENED && e.keyCode === 27) {
current.close();
}
Expand Down
4 changes: 2 additions & 2 deletions test/remodal_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@

QUnit.asyncTest('Esc key up', function(assert) {
$document.one('opened', '[data-remodal-id=modal]', function() {
$document.trigger($.Event('keyup', { keyCode: 27 }));
$document.trigger($.Event('keydown', { keyCode: 27 }));
});

$document.one('closed', '[data-remodal-id=modal]', function() {
Expand Down Expand Up @@ -356,7 +356,7 @@
var remodal = $('[data-remodal-id=modal2]').remodal();

$document.one('opened', '[data-remodal-id=modal2]', function() {
$document.trigger($.Event('keyup', { keyCode: 27 }));
$document.trigger($.Event('keydown', { keyCode: 27 }));

setTimeout(function() {
assert.equal(remodal.getState(), 'opened', 'it is still opened');
Expand Down

0 comments on commit 74e21c6

Please sign in to comment.