LoCo Day 28

Today I tried to solve the problem of the “ready to play” button swallowing keyboard input when the game starts, even though the button was disabled. Apparently jQuery doesn’t let you put the input focus on the document itself, which is where the keyboard input handler is attached. I ultimately settled on hiding the button entirely instead of disabling it after it’s been pressed, which has the result I wanted: putting the input focus on nothing in particular, so that the document sees the key presses.

This probably won’t work well if you start using the chat window again before the game starts, since the focus would still be in the text entry box, and arrow keys there will move the text cursor instead of moving your player avatar in the game, leading to much unhappiness as you get killed off before realizing what’s going on. So, this is more of a quick hack instead of an actual fix.

7 Responses

  1. Can you tell us what kind of game it is? I think that would help me visualize what kind of problems you are talking about right now. Is a game with Light Cycles? Because I’m imagining Light Cycles. I hope they’re Light Cycles.

  2. Yep, it’s Light Cycles, as long as you don’t mind using your imagination when it comes to the graphics.

  3. “As long as you don’t mind using your imagination”

    Clearly I do not.

    *hunches over holding a marker, pretending to ride a Light Cycle*

  4. Too bad you can’t “like” things on Paul’s blog, because I do like Ryan’s comments. If only Paul’s blog was more like Facebook…

  5. I could do that, but first I’d have to figure out a way to get all your personal information first.

  6. It’s in my wallet.

  7. D’aww, thanks Renee.

Comments are closed.