nurdism/neko

[BUG] Can't type certain keys in Firefox

duckinator opened this issue · 13 comments

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):

  • OS: Any?
  • Browser: Firefox
  • Version: Any?

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  | 

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?

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.

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)      =  ":"

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

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

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?

I am on a US English keyboard layout.

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

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

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

@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

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

@m1k1o just opened #68.