webcompat / web-bugs

A place to report bugs on websites.
https://webcompat.com
Mozilla Public License 2.0
746 stars 66 forks source link

www.typing.com - The semicolon key does not respond when playing a game #80013

Open mechboy88 opened 3 years ago

mechboy88 commented 3 years ago

URL: https://www.typing.com/student/game/keyboard-jump

Browser / Version: Firefox 89.0 Operating System: Windows 8.1 Tested Another Browser: Yes Chrome

Problem type: Something else Description: Semicolon key does not respond when game is running Steps to Reproduce: When the game is running in Firefox, the semicolon key does not respond at all. In Chrome and Edge, there are no problems with the semicolon key. Thanks.

View the screenshot Screenshot
Browser Configuration
  • None

From webcompat.com with ❤️

softvision-raul-bucata commented 3 years ago

@mechboy88 We appreciate your report. I was able to reproduce the issue. The semicolon (";") key does not respond when prompted:

Screenshot_34

For a better replication of this issue, from the link provided, select from the "Wordlist" the "All letters" option in order to see the semicolon playable option

Tested with:

Browser / Version: Firefox Release 89.0.2 (64-bit)/ Firefox Nightly 92.0a1 (2021-07-12) (64-bit)/ Chrome Version Version 91.0.4472.101 Operating System: Windows 10 PRO x64

Notes:

  1. Reproducible regardless of the status of ETP
  2. Reproducible on the latest build of Firefox Nightly
  3. Works as expected using Chrome

Moving this to NeedsDiagnosis for further investigations.

karlcow commented 2 years ago

This is working for me.

softvision-raul-bucata commented 2 years ago

The issue is still reproducible on my side. The semicolon keyboard is not accepted.

Firefox Nightly: semicolon

Chrome: semicolon chr

Tested with:

Browser / Version: Firefox Release 98.0 (64-bit)/ Firefox Nightly 100.0a1 (2022-03-14) (64-bit) /Chrome Version 99.0.4844.51 (Official Build) (64-bit) Operating System: Windows 10 PRO x64

This only happens when attempting to use the semicolon keyboard, and it seems that is Windows-specific.

Reopening this for further investigations.

[nv_11/2022]

softvision-raul-bucata commented 2 years ago

The issue is still reproducible:

semicolon

Tested with:

Browser / Version: Firefox Nightly 108.0a1 (2022-11-06) (64-bit) Operating System: Windows 10 PRO x64

[inv_45/2022]

karlcow commented 1 year ago
                document.body.addEventListener("keydown", (function() {
                    document.body.classList.remove("using-mouse")
                }))

then

r()(document).keydown(function(t) {
                    if ((t.metaKey || t.ctrlKey) && t.shiftKey && "d" === t.key)
                        return this.toggleDictation(), !1
                }.bind(this)),

then

            startListeners: function() {
                var t = this,
                    e = function(e) {
                        if (!e.defaultPrevented && t.isActive()) {
                            t.queue.push(e);
                            var i = t.keys[e.keyCode];
                            i && i.preventDefault && e.preventDefault()
                        }
                    };
                this.onKeyHandler = e,
                this.target.addEventListener("keydown", e, !1),
                this.target.addEventListener("keyup", e, !1),
                this.sceneInputPlugin.pluginEvents.on("update", this.update, this)
            },

on Safari macOS, I get 186 for the semicolon keyCode, but this is 59 in Gecko.

There is a: 59: ";",

I'm not sure why it breaks in Firefox, but I checked because I wanted to know why it was working in Safari.

wisniewskit commented 1 year ago

They have a handleInput function, which is called in Chrome when a semicolon is pressed, but not in Firefox:

  handleInput(char, forcedResult = undefined) {
    clearTimeout(this.idleTimeout);
    this.idleTimeout = setTimeout(this.autoPauseForIdle.bind(this), 10 * 1000);

    this.timer.paused = false;

    if (this.currentWordData) {
      this.currentWordData[this.highlightIndex].typed = true;

      // Correctly typed letter (or forced)
      if (char === this.currentWordData[this.highlightIndex].letter || forcedResult === true) {
        this.currentWordData[this.highlightIndex].success = true;
        this.highlightIndex++;

        this.player.smile();
        playSFX(this, this.typingGoodSFX, { volume: 0.6 });
      } else {
        this.currentWordData[this.highlightIndex].success = false;

        this.player.frown();
        playSFX(this, this.typingBadSFX, { volume: 0.6, errorSFX: this.registry.get('gameType') === 'inline' });

It's called from this handler:

    "inline" !== this.registry.get("gameType") && -1 === this.input.keyboard.eventNames().indexOf("keydown") && this.input.keyboard.on("keydown", function(e) {
        t.allowInput && (e.keyCode < 8 || e.keyCode > 46) && t.handleInput(e.key)
    }),

In Chrome allowInput is true, keycode is 186, and key is ';'. In Firefox, the handler is never even called. It looks like Firefox gets here, but no further:

update: function ()
{
  // snip some code
  //  Process the event queue, dispatching all of the events that have stored up
  for (var i = 0; i < len; i++)
  {
      var event = queue[i];
      var code = event.keyCode;

      if (event.type === 'keydown')
      {
          if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false))
          {
              //  Will emit a keyboard or keyup event
              this.emit(event.type, event);

              this.emit('keydown_' + KeyMap[code], event);
          }

          if (keys[code])
          {
              ProcessKeyDown(keys[code], event);
          }
      }
      else
      {
          //  Will emit a keyboard or keyup event
          this.emit(event.type, event);

          this.emit('keyup_' + KeyMap[code], event);

          if (keys[code])
          {
              ProcessKeyUp(keys[code], event);
          }
      }
  }
}

It fails because of this line:

if (KeyMap[code] && (keys[code] === undefined || keys[code].isDown === false))

KeyMap[code] is undefined, because code = 59 and there is no such code in the map. In Chrome the event.keyCode is 186 for the semicolon instead, which is where the map expects it.

We could probably make a sitepatch for this, but it seems worth checking if we can standardize these sorts of values properly, as it's unclear how many other keys the site might not recognize in its games as a result of expecting the same keycodes as Safari and Chrome provide. I've filed bz1841204 to see what we should do here.

wisniewskit commented 1 year ago

Unfortunately it doesn't seem likely that we can do anything here except reach out to the site to add the Firefox-specific keycodes to their maps when they detect Firefox, and possibly create a site-patch to do so for them which intercepts calls to Event.keyCode and returns the number they expect (based on their key-map, which can be found by searching their app.js for SEMICOLON or FORWARD_SLASH in the debugger).