Kongregate Keyboard input issues and fixes

Discussion of tools and resources for game developers

Post » Thu Jan 17, 2013 3:00 am

I just released my first C2 game on Kongregate and I found some issues about keyboard focus. Some I solved and others I had to make a workaround. As I didn't find any topic talking specificaly about this issues I think this could be good.

Issue #1 - Scrolls:
Vertical and Horizontal scrolls appeared on the game iFrame. I didnt really understand that because my width and height were not greater than the limites of Kong.
Every time I pressed the Right or Left key the horizontal scrolls slided. I fixed that adding this css code to the "index.html":

body { ... overflow:hidden; margin-left:0; margin-top:0; }

"Overflow" to hidden the scrolls and "margin-left" and "-top" to eliminate the bordes around the game.

Issue #2 - Up arrow:
Every time I pressed the "Up arrow" my hero jumped but also the hole page was rolling up. The odd thing here is that the game didn't lose any focus and the "Up arrow" was being used to jump in my game an at the same time to roll the page up (outside the game).
I didn't figured out how to solve this, so I changed the "Up arrow" input to the "Z" key.

Issue #3 - Space bar:
In some points of the game you had to use the "Space bar" to interact. Every time I had to press the "Space bar" the game was losing its focus.
Turns out that I was using the "Key is down" condition, wich oddly makes the game loses its focus. When I changed to "Key is pressed" it worked just fine.

I hope this can help somebody and if anyone has any solutions and suggestions I'll be glad to hear.

This the game by the way (wich is actually a gift I made to my girlfriend last christmas):

See ya!
Posts: 4
Reputation: 408

Post » Fri Apr 12, 2013 6:50 pm

Thanks for the post. I had a bit of trouble with losing focus too with the directional arrow keys. I ended up just using W, A, S, D as an alternative.

Also thanks for the CSS code to get rid of the scrollbars.
Posts: 5
Reputation: 1,082

Return to Tools and Resources

Who is online

Users browsing this forum: No registered users and 0 guests