ID:35726
 
i was recently working on a little project in BYOND and i came across an interesting problem. the project uses pixel movement, so the up arrow key moves you forward and the left/right arrow keys turn you. i was using something similar to loduwijk's KeyState library so that you can turn left or right while moving forward. the library works by having an HTML popup window use JavaScript to capture keyup/keydown events and relay them to DS via client.Topic().

there was a glitch, and it would happen rather frequently. i'd be holding down the up arrow, tap the left arrow to adjust my direction, and when i let go of the up arrow i'd keep moving forwards. it wasn't always that the up arrow key would "stick", it would happen to all keys. after inserting some debugging messages in the BYOND program and in the JavaScript, it seems that JavaScript is never calling its event handlers. its not that JavaScript's call to client.Topic() fails, but that the JS is never (in some cases) making the call at all.

maybe it was just my code. so i tried loduwijk's demo from his KeyState library. it doesn't have this problem, ever. this is strange because our programs are almost identical. the JavaScript code is essentially the same, and that's where the failure seems to be.

loduwijk's demo program and my project are different, but that shouldn't really matter. his demo lets you press keys to move a mob around the screen, mine too. his, being a demo, is a little simpler than mine, but that shouldn't affect it.

did you ever find a strange bug, one with no seemingly logical explanation, so instead of logically and systematically trying to track down the problem you try what would seem to be the most random solution and by some miracle it works? well that happened here. there is one difference between my program and loduwijk's: my program displays the coordinates of your mob in the stat panel, loduwijk's does not have any stat panels. i remove the stat panel from my program, and now i cannot produce the glitch. i add a stat panel to loduwijk's program, and now his demo has this glitch. DS's stat panel is affecting the execution of JavaScript code in an HTML popup? strange indeed.
Is this on the latest version (409)? We found very similar situation that was grid/stat specific due to some initialization code in those controls. I don't believe it would apply in your case (because it is backwards from the report), but it'd be good to know. Perhaps you can post this in Bug Reports so we can further investigate.