node-inspector can't console in nodev6.2.1 , Enter no reaction #951

Closed
trojanliu opened this Issue Nov 22, 2016 · 5 comments

Comments

Projects
None yet
5 participants
@trojanliu

trojanliu commented Nov 22, 2016

node v6.2.1
Node Inspector v0.12.8

i don't know why i can't console in the chrome54.0.2840.98.

Enter no reaction

image

image

@trojanliu trojanliu changed the title from node-inspector can console in nodev6.2.1 to node-inspector can't console in nodev6.2.1 , Enter no reaction Nov 22, 2016

@Fallenstedt

This comment has been minimized.

Show comment
Hide comment
@Fallenstedt

Fallenstedt Nov 23, 2016

I would give you 100 thumbs up if I could. I've been looking for a work around. Another person has mentioned this before at #942, however their solution did not work for me.

I would give you 100 thumbs up if I could. I've been looking for a work around. Another person has mentioned this before at #942, however their solution did not work for me.

@trojanliu

This comment has been minimized.

Show comment
Hide comment
@trojanliu

trojanliu Nov 23, 2016

I found the cause of the problem.

node-inspector/front-end/platform/DOMExtension.js
IsEnterKey method, judge enter event uses the event.keyIdentifier === "Enter".

but chrome 54.0 has remove "KeyboardEvent. KeyIdentifier"
aaaa

The solution is change the DOMExtension/isEnterKey 's function:

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

function isEnterKey(event) {
//suit for event.keyIdentifier
return (event.keyCode !== 229 && event.keyIdentifier === "Enter") || event.keyCode === 13;
}

trojanliu commented Nov 23, 2016

I found the cause of the problem.

node-inspector/front-end/platform/DOMExtension.js
IsEnterKey method, judge enter event uses the event.keyIdentifier === "Enter".

but chrome 54.0 has remove "KeyboardEvent. KeyIdentifier"
aaaa

The solution is change the DOMExtension/isEnterKey 's function:

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

function isEnterKey(event) {
//suit for event.keyIdentifier
return (event.keyCode !== 229 && event.keyIdentifier === "Enter") || event.keyCode === 13;
}

@bstro

This comment has been minimized.

Show comment
Hide comment
@bstro

bstro Jan 18, 2017

Seems like this issue should still be open?

bstro commented Jan 18, 2017

Seems like this issue should still be open?

@zxaos

This comment has been minimized.

Show comment
Hide comment
@zxaos

zxaos Jan 20, 2017

Might have been closed because dupe of #903?

zxaos commented Jan 20, 2017

Might have been closed because dupe of #903?

@TrevorSayre

This comment has been minimized.

Show comment
Hide comment
@TrevorSayre

TrevorSayre Mar 29, 2017

@trojanliu That will fix the Enter key, but not the other keys.

Since 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";
            case "ArrowLeft":
                return "Left";
            case "ArrowRight":
                return "Right";
            case "ArrowUp":
                return "Up";
            case "Tab":
                return "U+0009";
            case "Escape":
                return "U+001B";
            default:
                return this.key;
        } 
    }
});

@trojanliu That will fix the Enter key, but not the other keys.

Since 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";
            case "ArrowLeft":
                return "Left";
            case "ArrowRight":
                return "Right";
            case "ArrowUp":
                return "Up";
            case "Tab":
                return "U+0009";
            case "Escape":
                return "U+001B";
            default:
                return this.key;
        } 
    }
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment