Skip to content

Commit dc32543

Browse files
authored
Use key instead of keyCode
In non QWERTY keyboard, pressing S won't focus the search bar. This commit fixes the problem. Note that `keyCode` is not supported in IE8 already, so the fact that `key` is not supported in IE8 too doesn't really matter: the PR doesn't cause browser compatibility for the features to degrade.
1 parent b3f7015 commit dc32543

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scribble-lib/scribble/scribble-common.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function NormalizePath(path) {
129129

130130
function DoSearchKey(event, field, ver, top_path) {
131131
var val = field.value;
132-
if (event && event.keyCode == 13) {
132+
if (event && event.key === 'Enter') {
133133
var u = GetCookie("PLT_Root."+ver, null);
134134
if (u == null) u = top_path; // default: go to the top path
135135
u += "search/index.html?q=" + encodeURIComponent(val);
@@ -171,8 +171,8 @@ AddOnLoad(function(){
171171

172172
// Pressing "S" or "s" focuses on the "...search manuals..." text field
173173
AddOnLoad(function(){
174-
window.addEventListener("keyup", function(event) {
175-
if (event && (event.keyCode == 83 || event.keyCode == 115) && event.target == document.body) {
174+
window.addEventListener("keyup", function(e) {
175+
if ((e.key === 's' || e.key === 'S') && e.target === document.body) {
176176
var field = document.getElementsByClassName("searchbox")[0];
177177
field.focus();
178178
}

0 commit comments

Comments
 (0)