Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

MDL-34671 Stop browser receiving escape keydown in modal dialogues

In certain modal dialogues, we listen on the Escape key to close a
dialogue. However, this is still passed to the browser. As a result, if the
browser is in full screen mode and that browser respects the escape key as
a means to exit full screen.

As a result, we need to ensure that we listen for the escape key at keydown
rather than keyup, and additionally prevent the default browser behaviour.

This is a workaround to
and, should that issue be fixed, it should be removed.
  • Loading branch information...
commit 8a185b9ebc4ca891a4149009f3630d3dcf48ab06 1 parent b3778a0
@andrewnicols andrewnicols authored
5 course/yui/toolboxes/toolboxes.js
@@ -558,8 +558,9 @@ YUI.add('moodle-course-toolboxes', function(Y) {
// Cancel the edit if we lose focus or the escape key is pressed
thisevent = editor.on('blur', cancel_edittitle);
- thisevent ='document').on('keyup', function(e) {
- if (e.keyCode == 27) {
+ thisevent ='document').on('keydown', function(e) {
+ if (e.keyCode === 27) {
+ e.preventDefault();
2  lib/yui/chooserdialogue/chooserdialogue.js
@@ -144,7 +144,7 @@ YUI.add('moodle-core-chooserdialogue', function(Y) {
// Grab global keyup events and handle them
- thisevent ='document').on('keyup', this.handle_key_press, this);
+ thisevent ='document').on('keydown', this.handle_key_press, this);
// Add references to various elements we adjust
Please sign in to comment.
Something went wrong with that request. Please try again.