Processing.js and cross browser keycode compatibility
May 25, 2010 1 Comment
On Friday, I began looking (in more depth) at a ticket that started out as a simple problem of figuring out why an example sketch wasn’t working exactly like it’s Processing counterpart. It started out as a simple problem but turned into the urge to overhaul our current key input structure to something that works on all browsers. After much testing and figuring out how each browser treats keyCodes and key strokes, it is my recommendation to add a browser check and account for how each browser handles these items.
I used w3.org’s Keyboard Events and Codes page to figure out what each browser spit out as different keyCodes and charCodes. This helped me figure out that Opera is pitching out the % keyCode for pressing the left arrow key. As for key strokes, which was the original problem in the ticket, I used this site. It showed me that Chrome refires keydown events (on certain keys) when you hold a key down. This explains why the sketch works properly in Chrome but not in Firefox. To make it work like p5, we’d have to account for all of that and eventually make everything uniform.
My only question to the browser builders out there is… couldn’t you guys get together and standardize all this so users don’t have to worry so much about browser compatibility? *insert frowning face*