Add keyboard shortcut for /
Change-Id: If9a068eb199b5a16df8e5b4f80c7efe92353c088
This commit is contained in:
parent
a00491ddc8
commit
69886df6dd
@ -67,7 +67,20 @@ limitations under the License.
|
||||
notify: true,
|
||||
observer: '_valueChanged',
|
||||
},
|
||||
|
||||
_inputVal: String,
|
||||
_boundKeyHandler: {
|
||||
type: Function,
|
||||
value: function() { return this._handleKey.bind(this); },
|
||||
}
|
||||
},
|
||||
|
||||
attached: function() {
|
||||
document.body.addEventListener('keydown', this._boundKeyHandler);
|
||||
},
|
||||
|
||||
detached: function() {
|
||||
document.body.removeEventListener('keydown', this._boundKeyHandler);
|
||||
},
|
||||
|
||||
_valueChanged: function(value) {
|
||||
@ -86,6 +99,17 @@ limitations under the License.
|
||||
page.show('/q/' + this._inputVal);
|
||||
},
|
||||
|
||||
_handleKey: function(e) {
|
||||
if (util.shouldSupressKeyboardShortcut(e)) { return; }
|
||||
e.preventDefault();
|
||||
switch(e.keyCode) {
|
||||
case 191: // '/'
|
||||
var s = this.$.searchInput;
|
||||
s.focus();
|
||||
s.setSelectionRange(0, s.value.length);
|
||||
break;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
})();
|
||||
|
Loading…
Reference in New Issue
Block a user