Index: chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
diff --git a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
index fb34a147649ade3049aef041706237a478713609..c84092d121413645d27f610fcf75b9681bab67d9 100644 |
--- a/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
+++ b/chrome/browser/resources/media_router/elements/media_router_container/media_router_container.js |
@@ -500,7 +500,7 @@ Polymer({ |
ready: function() { |
this.elementReadyTimeMs_ = performance.now(); |
- document.addEventListener('keydown', this.checkForEscapePress_.bind(this)); |
+ document.addEventListener('keydown', this.onKeydown_.bind(this)); |
this.setSearchFocusHandlers_(); |
this.showSinkList_(); |
}, |
@@ -581,24 +581,6 @@ Polymer({ |
}, |
/** |
- * Catch an Escape button press when searching to cause it to only exit the |
- * filter view and not exit the dialog. |
- * @param {!Event} e Keydown event object for the event. |
- */ |
- checkForEscapePress_: function(e) { |
- if (e.keyCode == media_router.KEYCODE_ESC) { |
- if (this.isUserSearching_) { |
- this.showSinkList_(); |
- e.preventDefault(); |
- } else { |
- this.fire('close-dialog', { |
- pressEscToClose: true, |
- }); |
- } |
- } |
- }, |
- |
- /** |
* Compares two search match objects for sorting. Earlier and longer matches |
* are prioritized. |
* |
@@ -1332,6 +1314,29 @@ Polymer({ |
}, |
/** |
+ * Called when a keydown event is fired. |
+ * @param {!Event} e Keydown event object for the event. |
+ */ |
+ onKeydown_: function(e) { |
+ // The ESC key may be pressed with a combination of other keys. It is |
+ // handled on the C++ side instead of the JS side on non-mac platforms, |
+ // which uses toolkit-views. Handle the expected behavior on all platforms |
+ // here. |
+ if (e.keyCode == media_router.KEYCODE_ESC && !e.shiftKey && |
+ !e.ctrlKey && !e.altKey && !e.metaKey) { |
+ // When searching, allow ESC as a mechanism to leave the filter view. |
+ if (this.isUserSearching_) { |
+ this.showSinkList_(); |
+ e.preventDefault(); |
+ } else { |
+ this.fire('close-dialog', { |
+ pressEscToClose: true, |
+ }); |
+ } |
+ } |
+ }, |
+ |
+ /** |
* Called when a mouseleave event is triggered. |
* |
* @private |