Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keybinds take 2 presses #101

Closed
saxamaphone69 opened this issue Sep 7, 2024 · 4 comments
Closed

Keybinds take 2 presses #101

saxamaphone69 opened this issue Sep 7, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@saxamaphone69
Copy link

Enable Keybinds, press Q or F to show Quick Reply or activate Fappe Tyme, first press is the error, second press enables as expected.

Uncaught TypeError: Cannot read properties of undefined (reading 'toLowerCase')
    at userscript.html?name=4chan-XT.user.js&id=10d5d7a8-76a3-49ab-a7bd-3d6108ba965d:16375:43
    at Object.keyCode (userscript.html?name=4chan-XT.user.js&id=10d5d7a8-76a3-49ab-a7bd-3d6108ba965d:16381:11)
    at HTMLDocument.keydown (userscript.html?name=4chan-XT.user.js&id=10d5d7a8-76a3-49ab-a7bd-3d6108ba965d:16076:28)
    keyCode(e) {
      let key = (() => { let kc;
      switch ((kc = e.keyCode)) {
        case 8: // return
          return '';
        case 13:
          return 'Enter';
        case 27:
          return 'Esc';
        case 32:
          return 'Space';
        case 37:
          return 'Left';
        case 38:
          return 'Up';
        case 39:
          return 'Right';
        case 40:
          return 'Down';
        case 188:
          return 'Comma';
        case 190:
          return 'Period';
        case 191:
          return 'Slash';
        case 59: case 186:
          return 'Semicolon';
        default:
          if ((48 <= kc && kc <= 57) || (65 <= kc && kc <= 90)) { // 0-9, A-Z
->            return String.fromCharCode(kc).toLowerCase();
          } else if (96 <= kc && kc <= 105) { // numpad 0-9
            return String.fromCharCode(kc - 48).toLowerCase();
          } else {
            return null;
          }
      } })();
      if (key) {
        if (e.altKey) {   key = 'Alt+'   + key; }
        if (e.ctrlKey) {  key = 'Ctrl+'  + key; }
        if (e.metaKey) {  key = 'Meta+'  + key; }
        if (e.shiftKey) { key = 'Shift+' + key; }
      }
      return key;
    },

On another note, I had attempted a PR to stop using the deprecated keyCode, though not sure it directly translates here.

@TuxedoTako TuxedoTako added the bug Something isn't working label Sep 7, 2024
@TuxedoTako
Copy link
Owner

I can reproduce it. This is a weird one. String.fromCharCode() is supposed to be build in. How can it fail?

msedge_vYlqtOmcU3

@TuxedoTako
Copy link
Owner

Found it: String.fromCharCode is stubbed once, with // XXX Remove document-breaking ad as the only reason given, but even with my add blocker off, this isn't called by anything before my script.

TuxedoTako added a commit that referenced this issue Sep 7, 2024
- Fixed thread expansion in the index again. #97
- Fixed keybinds not working the first time. #101
@TuxedoTako
Copy link
Owner

Should be fixed in 2.13.3.

@saxamaphone69
Copy link
Author

Looks fixed on my end. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants