Permalink
Browse files

Provide reasonable keyboard binding for escape

  • Loading branch information...
1 parent 616ce7e commit dbe7ab68da3ddd054eaeca8cf48019789145c1ff @rwdaigle committed Oct 22, 2012
Showing with 8 additions and 1 deletion.
  1. +8 −1 app/assets/javascripts/search.js
@@ -107,14 +107,21 @@ var wireSearch = function() {
});
});
- Mousetrap.bind(['/', 'escape'], function(e) {
+ Mousetrap.bind(['/'], function(e) {
executeOutsideInputFields(e, function() {
searchField().focus().select();
$("#results .choice.selected").removeClass(selectedClass);
haltEvent(e);
});
});
+ Mousetrap.bind(['escape'], function(e) {
+ searchField().val('').focus().select();
+ $("#results").hide();
+ $("#search-error").hide();
+ haltEvent(e);
+ });
+
var haltEvent = function(event) {
event.stopPropagation();
event.preventDefault();

0 comments on commit dbe7ab6

Please sign in to comment.