Subject: Request for UIKeyCommand Support in Native iOS Wrapper for Bluetooth Keyboard Input

Subject: Request for UIKeyCommand Support in Native iOS Wrapper for Bluetooth Keyboard Input

Issue: We're building a hands-free workout app that uses Bluetooth foot pedals (keyboard mode) for input control. The app runs speech synthesis and timers simultaneously.

On iOS, once audio/media sessions are active (speech synthesis, timers), hardware keyboard events stop reaching the JavaScript layer in WKWebView. This is a known iOS behavior where WebKit suspends hardware keyboard event forwarding during active media sessions.

Current Behavior:

  • ✅ Bluetooth pedals work fine before workout starts

  • ✅ Pedals can type in native text fields

  • ❌ Pedals stop working once speech synthesis + timers begin

  • ❌ Events never reach JavaScript/DOM listeners

Root Cause: iOS changes responder priority during media sessions. WKWebView stops automatically forwarding hardware key events to the web layer. This cannot be fixed with JavaScript alone.

Solution Needed: Add UIKeyCommand handlers in the Base44 native Swift wrapper to capture hardware keyboard events at the UIKit level and inject them into the WKWebView as JavaScript events.

Requested Implementation:

override var canBecomeFirstResponder: Bool { return true } override var keyCommands: [UIKeyCommand]? { return [ UIKeyCommand(input: "q", modifierFlags: [], action: #selector(handleKeyQ)), UIKeyCommand(input: "e", modifierFlags: [], action: #selector(handleKeyE)), // Add other keys as needed ] } @objc func handleKeyQ() { injectKeyEvent("KeyQ", "q") } @objc func handleKeyE() { injectKeyEvent("KeyE", "e") } func injectKeyEvent(_ code: String, _ key: String) { let js = """ window.dispatchEvent(new KeyboardEvent('keydown', { code: '\(code)', key: '\(key)', bubbles: true })); """ webView.evaluateJavaScript(js, completionHandler: nil) } 

Why This Works: UIKeyCommand operates at the UIKit system level and doesn't depend on WebKit focus, DOM state, or media session priority. This ensures hardware keyboard events are always captured and forwarded to the web app.

Use Case: This enables professional fitness/workout apps with hands-free control, similar to native workout apps that support remote triggers during video recording and audio playback.

Alternative: If platform-wide implementation isn't feasible, please advise on how we can add a custom native bridge or wrapper for our specific app.

Thank you for considering this request!


This explains the technical issue clearly and provides the exact solution needed.

12 minutes ago

would this also then allow the camera to work at the same time

11 minutes ago

Revert

M

Base44 AI

Base44

Thought for 7s

Yes - UIKeyCommand captures keyboard events at the system level, completely independent of what's happening with the camera, audio, or timers in the web layer.

With this fix, you'd have:

  • ✅ Camera recording active

  • ✅ Speech synthesis playing

  • ✅ Timers running

  • ✅ Bluetooth pedals triggering actions

All working simultaneously, because the keyboard input is no longer competing with the media session - it's handled by UIKit and injected directly into the web app.

Please authenticate to join the conversation.

Upvoters
Status

In Review

Board
💡

Feature Request

Date

About 2 months ago

Author

Maykell Lorenzo

Subscribe to post

Get notified by email when there are changes.