LastKeyCode reported incorrectly in nwjs on Mac

0 favourites
  • 5 posts
  • Problem Description

    LastKeyCode reported incorrectly in nwjs on Mac for keys on the numeric pad.

    Example: Numeric Keypad key "1" is reported as code 49 and it should be 97.

    nwjs on Windows works fantastically and no browsers exhibit this issue on either Mac or Windows.

    This issue was initially discussed in post this post.

    Attach a Capx

    Link: keytestcapx.zip

    I don't see right off where to upload a .capx to this actual post, please see link above.

    Description of Capx

    In a text object, the .capx displays LastKeyCode when pressed and generates a Javascript alert of the same.

    In nwjs on Mac, LastKeyCode is incorrect for numkeys but the Java alert recognizes the key properly. The Java alert is there to effectively eliminate nwjs itself from the equation.

    Steps to Reproduce Bug

    • Export provided capx to nwjs on Mac.
    • Run the app; press a numpad key
    • The java alert is correct but the text object in the capx displays the wrong (non numpad) key.

    Observed Result

    LastKeyCode for numeric keys are reported incorrectly as their non-numeric counterparts

    Expected Result

    LastKeyCode should be correct for numkeys and consistent with the non-nwjs browser experience

    Affected Browsers

    Browsers do not exhibit the issue. Only nwjs on mac. nwjs on Windows works as expected.

    I don't see this issue on Safari, Chrome, IE, Edge, Firefox, FireFox Nightly.. everything is fine.

    Operating System and Service Pack

    MacOS El Capitan, Sierra, High Sierra. Occurs on both VM and real Mac hardware (Macbook Pro 2016)

    nwjs 21, 24, 25 have been tested.

    Construct 2 Version ID

    244, 247 beta

    Appreciate whomever checks this one out! This is, unfortunately, a showstopper for my particular application which is targeted primarily for Mac users... and it was determined late in the development cycle that nwjs was going to be a requirement. Thanks, -Steve

  • Also, would anyone that would be able to test this in Construct 3 Beta?

    (by downloading keytestcapx.zip then compiling it in njws for Mac and seeing if LastKeyCode is correct for numpad keys). Nwjs export is not permitted in the free public beta. I'd also love to test this with a temporary access code for C3 if one is available.

    Thanks!

    -Steve

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • On further inspection, the above results remain true (on Mac nw.js) but JS event.keyCode is also incorrect.

    This is what is observed (on Mac nw.js) alltogether:

      C2's Keyboard.LastKeyCode is incorrect for numpad keys browser.execjs("event.code") is correct for numpad keys browser.execjs("event.keyCode") is incorrect for numpad keys.

    Example: LastKey2.zip

    Therefore, it seems that a workaround to properly detect numkeys on Mac nw.js is to leverage event.code from JavaScript and manually derive a keycode from that. Still not certain if this would occur in C3.

    Most importantly, I can also reproduce this on Mac outside of nw.js using the latest version of Chrome (62.0.3202.75)

  • The LastKeyCode value is provided by the browser/OS, not Construct, so I'm not sure there's much we can do about this without breaking existing projects. Perhaps we should add a new expression.

  • Thanks for the reply, Ashley! Yes, after a lot of self investigation I'd found that event.keyCode was also incorrect and the issue is reproducible without Construct.

    Since event.code does not exhibit this issue on Chrome or Chromium on MacOs, I agree that adding event.code into the keyboard object in Construct might be useful. That way there is an option to get a string from the keypress directly without relying on the keycode. StringFromKeyCode would provide the string for the incorrect key in this case, due to the overall issue (which is a essentially an event.keyCode Chrome/Chromium bug on MacOS).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)