Keypress on Ipad

0 favourites
  • 6 posts
  • I?m trying to make an activity for an Ipad which is controlled by ?key presses? from a Bluetooth keyboard. The activity works on Windows and Mac machines (from their own keyboards) but not on an Ipad. The Ipad is ok with Touch activation but not when it comes to external key presses. (The bluetooth keyboard does work in 'word processor' apps.) I would be grateful if anyone has any suggestions.

  • The Keyboard object listens to keydown and keyup events. If it doesn't work it might be a problem with your bluetooth keyboard.

  • Thanks Ashley - I will buy another keyboard and try again.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • david0vincent, Ashley : It's not the keyboard fault. It's just the way Safari on iOS handle keyboard events.

    From http://stackoverflow.com/a/4804590 :

    Safari for iOS doesn't trigger keyboard events on DOM elements that are not components of a form. This includes the document and body which are usually used to capture keystrokes anywhere on the page.

    The only way to trigger a keystroke event on document or body of a page is to trigger it in an input or textarea. In that case, the event will correctly 'bubble' to the body and document.

    However, this might be a problem because Safari for iOS doesn't allow us to give an element focus from javascript.

    At the moment, we are using a solution where user has to click on an input field before starting the first scan, and the input field is then moved off-screen but retains focus.

  • Great job Pode - sounds like a possible solution. Very grateful.

  • Hello, I am developing an iPad music app with a virtual qwerty keyboard as the interface.   I would like to be able to �play� this app from a Bluetooth keyboard as well. This seems to work fine with KEYDOWN messages but does not follow with a KEYUP message when the key is released. Any insight and ideas for solutions are most welcomed. Thanks, Jim

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)