[ruby/rdoc] [DOC] Fix to use KeyboardEvent.key over keyCode

https://github.com/ruby/rdoc/commit/663edc807c
This commit is contained in:
gemmaro 2023-07-05 03:39:14 +00:00 committed by git
parent 77fa4787bd
commit 62754503d8
2 changed files with 11 additions and 11 deletions

View File

@ -15,9 +15,9 @@ Search.prototype = Object.assign({}, Navigation, new function() {
this.init = function() { this.init = function() {
var _this = this; var _this = this;
var observer = function(e) { var observer = function(e) {
switch(e.keyCode) { switch(e.key) {
case 38: // Event.KEY_UP case 'ArrowUp':
case 40: // Event.KEY_DOWN case 'ArrowDown':
return; return;
} }
_this.search(_this.input.value); _this.search(_this.input.value);

View File

@ -23,24 +23,24 @@ Navigation = new function() {
this.onkeydown = function(e) { this.onkeydown = function(e) {
if (!this.navigationActive) return; if (!this.navigationActive) return;
switch(e.keyCode) { switch(e.key) {
case 37: //Event.KEY_LEFT: case 'ArrowLeft':
if (this.moveLeft()) e.preventDefault(); if (this.moveLeft()) e.preventDefault();
break; break;
case 38: //Event.KEY_UP: case 'ArrowUp':
if (e.keyCode == 38 || e.ctrlKey) { if (e.key == 'ArrowUp' || e.ctrlKey) {
if (this.moveUp()) e.preventDefault(); if (this.moveUp()) e.preventDefault();
} }
break; break;
case 39: //Event.KEY_RIGHT: case 'ArrowRight':
if (this.moveRight()) e.preventDefault(); if (this.moveRight()) e.preventDefault();
break; break;
case 40: //Event.KEY_DOWN: case 'ArrowDown':
if (e.keyCode == 40 || e.ctrlKey) { if (e.key == 'ArrowDown' || e.ctrlKey) {
if (this.moveDown()) e.preventDefault(); if (this.moveDown()) e.preventDefault();
} }
break; break;
case 13: //Event.KEY_RETURN: case 'Enter':
if (this.current) e.preventDefault(); if (this.current) e.preventDefault();
this.select(this.current); this.select(this.current);
break; break;