@josh-k I see, it indeed seems like capturing keyboard events without having a text field focused has been restricted since iOS 18.
There might be workarounds but I have not tried them personally, but maybe try this:
Set "contenteditable" to "true" on an element, and have the user tap the element to give it focus:
<div id="editor" contenteditable="true">Tap here</div>