@@ -40,6 +40,29 @@ if (!DOMTokenList.prototype.remove) {
4040 } ;
4141}
4242
43+
44+ // Gets the human-readable string for the virtual-key code of the
45+ // given KeyboardEvent, ev.
46+ //
47+ // This function is meant as a polyfill for KeyboardEvent#key,
48+ // since it is not supported in Trident. We also test for
49+ // KeyboardEvent#keyCode because the handleShortcut handler is
50+ // also registered for the keydown event, because Blink doesn't fire
51+ // keypress on hitting the Escape key.
52+ //
53+ // So I guess you could say things are getting pretty interoperable.
54+ function getVirtualKey ( ev ) {
55+ if ( "key" in ev && typeof ev . key != "undefined" ) {
56+ return ev . key ;
57+ }
58+
59+ var c = ev . charCode || ev . keyCode ;
60+ if ( c == 27 ) {
61+ return "Escape" ;
62+ }
63+ return String . fromCharCode ( c ) ;
64+ }
65+
4366function getSearchInput ( ) {
4467 return document . getElementsByClassName ( "search-input" ) [ 0 ] ;
4568}
@@ -323,28 +346,6 @@ function defocusSearchBar() {
323346 }
324347 }
325348
326- // Gets the human-readable string for the virtual-key code of the
327- // given KeyboardEvent, ev.
328- //
329- // This function is meant as a polyfill for KeyboardEvent#key,
330- // since it is not supported in Trident. We also test for
331- // KeyboardEvent#keyCode because the handleShortcut handler is
332- // also registered for the keydown event, because Blink doesn't fire
333- // keypress on hitting the Escape key.
334- //
335- // So I guess you could say things are getting pretty interoperable.
336- function getVirtualKey ( ev ) {
337- if ( "key" in ev && typeof ev . key != "undefined" ) {
338- return ev . key ;
339- }
340-
341- var c = ev . charCode || ev . keyCode ;
342- if ( c == 27 ) {
343- return "Escape" ;
344- }
345- return String . fromCharCode ( c ) ;
346- }
347-
348349 function getHelpElement ( ) {
349350 buildHelperPopup ( ) ;
350351 return document . getElementById ( "help" ) ;
0 commit comments