This issue still exist and applies to enter as well. It sometimes catches the input, but it is very inconsistent and mostly doesn’t register. I’m testing on safari, on an iPhone 7 something. This would improve the experience for mobile web development if it was fixed.
My guess is that is an issue for keys that aren’t standard text / number input. Anything that wouldn’t appear in input.text really.
Until this gets resolved, here is the workaround I’m using:
This goes at the bottom of the html template:
<!-- horribly ugly workaround -->
<script>
let pressedKeys = {}
document.getElementsByTagName("body")[0].addEventListener("keydown", function(ev) {
pressedKeys[ev.code] = true
})
function CheckForKey(keycode) {
//console.log(pressedKeys)
if ( pressedKeys[keycode] ) {
pressedKeys[keycode] = undefined
return true
}
return false
}
</script>
This is in a .script component:
function update(self, dt)
if (html5) then
local enter_pressed = html5.run([[CheckForKey("Enter")]])
local backspace_pressed = html5.run([[CheckForKey("Backspace")]])
if enter_pressed == "true" then
--do stuff
end
if backspace_pressed == "true" then
--do stuff
end
end
end
Works pretty well. My performance loving brain is very sad.