From 50ccb83a584f8cc55582a063f53f813f698d36c7 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Sat, 13 Oct 2012 22:27:40 +0000 Subject: [PATCH] Hide on pressing ESC key until next input change --- hinter.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hinter.js b/hinter.js index e43c4c7..f0e0169 100644 --- a/hinter.js +++ b/hinter.js @@ -378,7 +378,7 @@ SimpleAutocomplete.prototype.onChange = function() SimpleAutocomplete.prototype.onKeyUp = function(ev) { ev = ev||window.event; - if (ev.keyCode != 10 && ev.keyCode != 13) + if (ev.keyCode == 38 || ev.keyCode == 40) this.show(); if (ev.keyCode == 38 || ev.keyCode == 40 || ev.keyCode == 10 || ev.keyCode == 13) { @@ -421,6 +421,11 @@ SimpleAutocomplete.prototype.onKeyPress = function(ev) this.selectItem(this.selectedIndex); return stopEvent(ev, true, true); } + else if (ev.keyCode == 27) // escape + { + this.hide(); + return stopEvent(ev, true, true); + } else return true; // scrolling @@ -441,6 +446,8 @@ SimpleAutocomplete.prototype.onKeyPress = function(ev) // Called when input receives focus SimpleAutocomplete.prototype.onInputFocus = function() { + if (this.disabledUntil) + this.enable(); this.show(); this.input.autocomplete = 'off'; this.hasFocus = true;