toggle virtual keyboard when external barcode scanner is connected by USB swift - swift

I have a USB barcode scanner which acts as a HID keyboard (I think). When I connected to iPhone, the virtual Keyboard immediately get hidden.
How can I toggle the virtual keyboard in Swift?
BTW I really really wonder why we still can not do that easily in 2022
Thank you very much

Related

Detecting if an external mouse is connected in Swift?

For an app I am making on macOS I want different behaviour for the trackpad vs. a mouse. Is there any way to check if an external mouse is connected (e.g via usb or bluetooth) to the mac in Swift? I.e the assumption will be that if an external mouse is connected then the user will be using that rather than the trackpad. If they have an external mouse connected but would like to use the trackpad as as a pointer then they can change this in a settings menu.

Detect if a physical keyboard is connected in Flutter

Is there a way to detect if there is a PHYSICAL keyboard connected in Flutter? I would like to detect if the user is using a physical keyboard, and alter the UI depending on if this is so.
Has this changed? I would also like to detect if a keyboard is connected/available. I'm currently reacting when a physical keyboard is used with a RawKeyboardListener but it would be a smoother experience for the end user if I could see if a keyboard was connected, before it's actually used.
Looks like this is available in Android native: https://developer.android.com/reference/android/content/res/Configuration.html#keyboard
Not sure if it's available on iOS but we have the RawKeyboardListener approach that is OK on iOS. For Android we are supporting Chromebooks with physical keyboards and to provide the best experience we would like to react as early as possible to physical keyboards.
If you want to know if the physical keyboard has been used (but not when it connects), you could listen to keyboard events by listening to RawKeyboard.instance.addListener, and switch modes if you see a key event: RawKeyboard only sends physical keyboard events.
But to answer your question, no, there's no specific notification for when a physical keyboard is connected.

Use USB keyboard for text input in Smart TV application

My application has implemented custom onscreen-keyboard.
Is there a way to support the USB keyboard connected to a TV? By default, Samsung TV translates some keystrokes to remote control codes (0-9, red, blue, etc..). Is there a way to get all keystrokes? Preferably without the use of IME.
UPDATE:
I want to implement text input from the USB keyboard within my own onscreen virtual keyboard. By default, letter keys are not translated to application.
TV: UE46ES8000, USB, and BT keyboards connected and allow to control application, but unable to input text in it.
You can connect keybords to your SmartTV but your TV need to support them.
In example this samsung keybord: http://www.samsung.com/uk/consumer/tv-audio-video/television/tv-accessories/VG-KBD1500/XU-spec?subsubtype=wireless-keyboard
is compatible with:
Samsung SMART TV: LED ES6100 series and above, PDP E550 series and above
So if your TV device support USB or wireless keybord you do not need to translate any key codes in your application it will just work.

Force on screen keyboard to show when bluetooth keyboard connected

I have to have a bluetooth scanner connected to an app I am developing. The scanner acts as a keyboard input but there are no keys, only a button to scan with. The problem I am running into is there are a few UITextFields that a user needs to interact with on the screen.
When the user taps the textfield to enter in data, no keyboard pops up because the iOS thinks there is a full keyboard attached via bluetooth.
How can I force the screen keyboard to show up when the UITextField "becomes first responder" ?
Thanks in advance!
The problem is that the Bluetooth scanner is pretending to be a Bluetooth keyboard, so iOS thinks that it doesn't need to show the onscreen one.
Unfortunately there's no easy answer for this. Some scanners have a button you can press that will force the onscreen keyboard to come up. Some allow you to pair in "iPhone mode" (or something similar) so that it doesn't act as a Bluetooth keyboard.
This answer to a related question (https://stackoverflow.com/a/3837131/493988) has what seems like a hack based on a UITextField's inputAccessoryView, but I haven't personally verified it so I can't say much about it. Good luck!
Have you tried [myTextField becomeFirstResponder];?

Bluetooth Scanner sets system-wide keyboard, UITextFields wont show soft keyboard on responder

This is a bit curly, and I am not sure there is an answer.
I have a simple application that uses a handheld bluetooth scanner paired to an iPhone to keep lists of parcels coming of the back of trucks.
The scanner acts-as a keyboard sending character strings on scan. In the application the user must pair with the scanner in settings.
Upon scan complete a textfield is populated with the sent string. The last character is a return char, at which time the contents are added to a datasource for a UITableView.
The problem is this; Once the scanner has been used once the system seems to recognize it as the only user input. Any future attempt to bring up the soft keyboard fails. This goes beyond the scanning application ~ quitting the app completely and attempting to use Apples SMS app also fails to bring up the keyboard.
Is there any (apple legal) way of either using both or setting preferred input device? There seems to be a myriad of legal issues around Bluetooth and accessories, I am wondering if I am out of luck. Has anyone heard of anything that might help me out?
It appears I am not alone (as in this post regarding iPad soft keyboard)
I think you've pretty much covered it.
According to HT4111:
You can stop using a Bluetooth accessory by either turning off the accessory, or turning off Bluetooth on iPad.
According to Gizmodo's 10 iPad Essential Tips & Tricks:
When you have a Bluetooth keyboard connected to your iPad, the virtual keyboard will cease to appear. (This is a good thing.) However, what if, for some random reason, you needed that virtual keyboard? Don't unpair your Bluetooth. Just... Hit the eject key on Apple's physical keyboard. It'll bring up the virtual one.
If there's an off button on the scanner, then hit that. If you have an actual bluetooth keyboard, then use that (or hit its eject button if it's an Apple keyboard). If you have control over the design of the scanner hardware, then you can add a "show keyboard" button (I'm not sure which keycode Apple uses for "eject") if turning it off is too tedious.
Socket Mobile just added a new "double tap" feature to their Bluetooth barcode scanner that lets you open the onscreen keboard. There's a video demo on YouTube. http://www.youtube.com/socketmobile