Keypress on Ipad

Get help using Construct 2

Post » Fri Sep 07, 2012 10:02 am

Im 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.
B
3
G
1
Posts: 10
Reputation: 595

Post » Fri Sep 07, 2012 12:59 pm

The Keyboard object listens to keydown and keyup events. If it doesn't work it might be a problem with your bluetooth keyboard.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Fri Sep 07, 2012 1:52 pm

Thanks Ashley - I will buy another keyboard and try again.
B
3
G
1
Posts: 10
Reputation: 595

Post » Fri Sep 07, 2012 3:39 pm

@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 :
[quote]
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.
[/quote]
B
33
S
9
G
6
Posts: 709
Reputation: 6,704

Post » Fri Sep 07, 2012 3:50 pm

Great job Pode - sounds like a possible solution. Very grateful.
B
3
G
1
Posts: 10
Reputation: 595

Post » Sun Feb 17, 2013 7:36 am

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
B
1
Posts: 1
Reputation: 277


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 16 guests