Jump to content

Keyboard Support


evanxg
 Share

Recommended Posts

Helo guys,

I started writing a spaceship  game with pandaJs.

But I am not getting the right behavior for the keyboard keydown event.

What I am expecting is the keydown callback to be called multiple times as long as the any key is down but it only fires once.

 

I want my ship to keep moving left when KEY_LEFT is held down

Or to keep firing when KEY_SPACE  is down 

 

I looked into the source code of panda Js and modified the line  210 file: https://github.com/ekelokorpi/panda.js/blob/master/src/engine/keyboard.js

I commented the line 210 so it keep calling back however the there is a delay between the first call and the subsequent call of the keydown callback:

for instance holding the LEFT_KEY makes the ship moves one step to the left (one step is 6px) and then wait some milliseconds before starting a continues move to the left.

 I am not able to fix that. Please help.

 

I think there should be a configuration member to the keyboard module so that I can enable continuous firing of the keydown or at least this should be the default behaviour as in most cases.

 

thanks in advance 

 

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...