Chrome inspector console does not work with version 54.0.2840.99

落爺英雄遲暮 提交于 2019-12-05 22:25:05

It's caused by Chrome deprecating KeyboardEvent.keyIdentifier.

The workaround would be to add keyIdentifier back to the KeyboardEvent prototype.

I also noticed that the KeyboardEvent.key string values are different from those from KeyboardEvent.keyIdentifier so I show below how to handle those differences if needed.

Object.defineProperty(KeyboardEvent.prototype, 'keyIdentifier', {
    get: function() {
        switch (this.key) {
            case "ArrowDown":
                return "Down";
                break;
            case "ArrowLeft":
                return "Left";
                break;
            case "ArrowRight":
                return "Right";
                break;
            case "ArrowUp":
                return "Up";
                break;
            case "Tab":
                return "U+0009";
                break;
            case "Escape":
                return "U+001B";
                break;
            default:
                return this.key;
        } 
    }
});

Simply replacing isEnterKey() is not sufficient and the above code handles this fix.

A workaround, as suggested here, by trojanliu would be editing DOMExtension.js file, changing the isEnterKey() function...

vi /usr/local/lib/node_modules/node-inspector/front-end/platform/DOMExtension.js 
/isEnterKey

... to check for the keyCode === 13:

function isEnterKey(event) {
  //suit for event.keyIdentifier
  return (event.keyCode !== 229 && event.keyIdentifier === "Enter") || event.keyCode === 13;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!