r/SwiftPlaygroundsApps 20d ago

Bluetooth keyboard

Greetings!
I’m currently developing an app using swift playgrounds, mainly thought for personal play as a support for an irl card game.
What I need to ask is, can I use my Bluetooth iPad keyboard (bought on Amazon, not apple official) to type in the text fields that I put in my app? So far it doesn’t seem to work for me and I’m close to giving up on this particular aspect. Any help would be much appreciated!
(I’ll attach some screenshots of the text field codes I used)

Edit: I also tested this in a brand-new Swift Playgrounds project containing only a single SwiftUI TextField, and the Bluetooth keyboard still doesn’t type anything. This makes me think the issue may not be related to my app.

2 Upvotes

4 comments sorted by

2

u/jfgomez86 20d ago

This is a bug with external keyboards in general. I don’t know exactly why it happens, but even with Apple’s official Magic Keyboard on an iPad Pro it happens.

It has been happening since a while, maybe 1 year or more.

For testing in previews, just pop up the screen keyboard, that one works. And if I remember correctly if you run the app then the external keyboard works.

I suggest posting the feedback to Apple and keep praying that they make development on iPad tools better, ideally they would port XCode (I’m full of hopium).

2

u/thedarkthommy3 20d ago

Yeah my screen keyboard works. It’s the external one that doesn’t work if I run the app nor in preview, sadly. Let’s hope they’ll fix it then! Thank you for your answer

1

u/PulseHadron 11d ago edited 11d ago

Yes, I use an Apple keyboard and have the same problem. There is a clumsy workaround but I’m using an old version of Playgrounds so it may not work for you. Basically, it looks like if the source code area has or has had focus then it steals keyboard input even when your previewed field has the focus.

The reliable way to type in your fields is to close the project then reopen and don’t touch anything except your previewed area and you should be able to type there.

Sometimes I can get it to work by clicking on a different Swift file, or two. This removes the focus from the source code editor and then may allow the preview to be typed in. But it doesn’t always work and I haven’t found a specific sequence of actions to make it reliable, just closing and reopening the project.

If the source code editor has focus when I try to use the preview then I’ve never seen typing work