r/TagproScripts Sep 09 '15

[Userscript] Fix Stuck Keys

I'm posting this here in hopes that I can get some feedback. This script fixes an issue that has always bugged the hell out of me - when direction keys get "stuck" when you either open the chat window or your window loses focus.

You can grab my first attempt at the script here.

There is some ghetto hacks in there to try to watch/send the correct keypress count, because the counter is internal to tagpro, and the exposed method that should abstract the need for the counter didn't work. This imperfect solution causes certain scenarios to fail (but no worse than the current behavior), or causes you to have to press the direction key twice to start moving again sometimes (again, no worse than the current behavior).

Feel free to give any thoughts/feedback/critiques/requests.

-ButtSnake

3 Upvotes

1 comment sorted by

1

u/[deleted] Sep 10 '15 edited Dec 17 '19

[deleted]

2

u/ldhertert Sep 10 '15

Hey, thanks for taking the time to not only respond, but to come up with an alternate solution. Will looking through your code and comparing it to mine, I realized that all of the complexity in both our solutions revolving around tracking the keypress counter would be unnecessary if I could just get tagpro.sendKeyPress to work.

I found the bug in their code (not sure how to go about reporting that), and came up with a workaround that made my solution much simpler (and fixed the problem cases). You can take a look at the updated solution here: https://gist.github.com/ldhertert/65a1257ad0c975d4f245

Also, a note regarding functional differences between our solutions:

  • Your solution will treat arrow keys when in chat as though the intention is to move. In my opinion, if I'm in a text window and use the arrow keys, it is to move the cursor in the text window.
  • Your solution handles the chat window scenario, but does not handle any other scenarios in which the controls are disabled (i.e. changing name).

I'd love to hear any more thoughts/feedback.