csp-games Guest |
Quote
|
2021-02-12 02:17:08 |
|
I would consider itch.io a standard test for compatibility when it comes to browser games. Pity the CC keyboard handler does not work there. CC does itself no favor this way.
I didn't expect I have to write my own. However, I did that for other games, and it worked from the getgo.
|
csp-games Guest |
Quote
|
2021-02-12 17:58:03 |
|
little update: I swear the cursor keys didn't work at all when I first tested the upload on itch.io. Then a bit later they suddently worked "a bit", in that, the page was still scrolling, but the game also received the keys. There is an option called "e.preventDefault()" that gives the script the exclusive control over page control keys (games on itch.io run inside an iframe, but focus or not, cursor keys scroll the parent page in the CC export).
here's a sample, note I had to "scramble" some JS event handler names, as the forum would otherwise omit them.
function keyinit() { window.captureEvents(Event.KEYPRESS); window.o.n.k.eypress= keymerk; window.captureEvents(Event.KEYDOWN); window.o.n.k.eydown= keymerk; window.captureEvents(Event.KEYUP); window.o.n.k.eyup= keyrelease; } function keymerk(e) { var whatkey = event.keyCode; //get ascii of keyboard input if (whatkey == 37) { bb2js__cursor_right=1; e.preventDefault(); } if (whatkey == 39) { bb2js__cursor_left=1; e.preventDefault(); } if (whatkey == 38) { bb2js__cursor_up=1; e.preventDefault(); } if (whatkey == 40) { bb2js__cursor_down=1; e.preventDefault(); } if (whatkey == 27) { bb2js__end_it_all=1; } }
this, whether correct, proper or professional code or not, works in the itch.io iframe, once it has the focus.
|
54newstar Registered User |
Quote
|
2021-06-29 21:16:20 |
|
Can you create a downloadable google text of this or a googledrive etc file of this please?
|