nurdism / neko

A self hosted virtual browser (rabb.it clone) that runs in docker.
Apache License 2.0
2.03k stars 185 forks source link

[BUG] Can't type certain keys in Firefox #51

Closed duckinator closed 4 years ago

duckinator commented 4 years ago

Describe the bug Certain keys — namely -/_, =/+, ;/: — can't be typed at all. The server logs say error="invalid key <...>"

To Reproduce Steps to reproduce the behavior (EDIT: In Firefox):

  1. Connect to a Neko instance
  2. Try typing a colon
  3. Note that it doesn't work

Expected behavior All standard keys work.

Desktop (please complete the following information):

Additional context I believe this is due to them not being specified in https://github.com/nurdism/neko/blob/master/server/internal/xorg/keycode/keys.go and https://github.com/nurdism/neko/blob/master/server/internal/xorg/xorg.go

EDIT: See comment from @nurdism.

Client Log: (No output when typing -=; and not in debug mode.)

Server Log: Here are the logs from trying to type -=;:

neko_1  | 2020-03-27 03:42:24,479 DEBG 'neko' stdout output:
neko_1  | 3:42AM WRN key down failed error="invalid key 173" module=webrtc
neko_1  | 
neko_1  | 2020-03-27 03:42:24,650 DEBG 'neko' stdout output:
neko_1  | 3:42AM WRN keyup failed error="invalid key 173" module=webrtc
neko_1  | 
neko_1  | 2020-03-27 03:42:25,438 DEBG 'neko' stdout output:
neko_1  | 3:42AM WRN key down failed error="invalid key 61" module=webrtc
neko_1  | 
neko_1  | 2020-03-27 03:42:25,591 DEBG 'neko' stdout output:
neko_1  | 3:42AM WRN keyup failed error="invalid key 61" module=webrtc
neko_1  | 
neko_1  | 2020-03-27 03:42:26,569 DEBG 'neko' stdout output:
neko_1  | 3:42AM WRN key down failed error="invalid key 59" module=webrtc
neko_1  | 
neko_1  | 2020-03-27 03:42:26,728 DEBG 'neko' stdout output:
neko_1  | 3:42AM WRN keyup failed error="invalid key 59" module=webrtc
neko_1  | 
duckinator commented 4 years ago

I'm noticing that a few of them are specified in those two files I mentioned, but the values are different than the errors I get. Maybe this could be due different keyboard layouts, or something like that?

duckinator commented 4 years ago

Also, -/_, =/+, and ;/: are the only keys not working for me. I'm using a normal US English layout on Fedora 31, but other people have the same problem on at least Manjaro Linux.

duckinator commented 4 years ago

Here's what xev reports on my system, in case it's helpful.

The format is keycode <KEYCODE> (keysym <KEYSYM>, <name>) = <string representation>.

keycode 20 (keysym 0x2d, minus)      =  "-"
keycode 20 (keysym 0x5f, underscore) =  "_"
keycode 21 (keysym 0x3d, equal)      =  "="
keycode 21 (keysym 0x2b, plus)       =  "+"
keycode 47 (keysym 0x3b, semicolon)  =  ";"
keycode 47 (keysym 0x3a, colon)      =  ":"
GigaFyde commented 4 years ago

Cannot reproduce, all the characters you have mentioned can be typed without issues.

GigaFyde commented 4 years ago

I do suspect that this has to do with keyboard mapping.

duckinator commented 4 years ago

I and the group I was watching things with reproduced it on at least 3 systems. Are you using an US English keyboard layout, or something else?

GigaFyde commented 4 years ago

I am on a US English keyboard layout.

nurdism commented 4 years ago

what browser are you using @duckinator I haven't been able to reproduce this either. Your browser might not be sending out standard key codes.

I just looked it up, your using firefox and the key codes are kinda funky with ff. keycode 61 can be a semicolon (ff) or equals, keycode 61 on ff is equals but nothing on any other browser and keycode 173 is minus (ff), mute/unmute on others.

Note to self: This should be corrected client side, just alter the code to standard. https://github.com/nurdism/neko/blob/master/client/src/components/video.vue#L466

duckinator commented 4 years ago

@nurdism sorry, looks like I was mistaken about it happening in other browsers. Updated the description of the issue accordingly. :slightly_smiling_face:

duckinator commented 4 years ago

@nurdism just tried the latest version in Firefox. - = ; work but not _ + : — the latter group being the first one, but with shift pressed.

duckinator commented 4 years ago

@nurdism I think changing https://github.com/nurdism/neko/blob/master/client/src/components/video.vue#L469-L479 to something like this might do the trick, but I'm not sure:

      if (key === 59 && (e.key === ';' || e.key === ':')) {
        key = 186
      }

      if (key === 61 && (e.key === '=' || e.key === '+')) {
        key = 187
      }

      if (key === 173 && (e.key === '-' || e.key === '_')) {
        key = 189
      }
m1k1o commented 4 years ago

@duckinator I tried it, it absolutely does fix the issue! Feel free to add PR.

duckinator commented 4 years ago

@m1k1o just opened #68.