How to detect if mobile browser? #3183
Answered
by
hajimehoshi
esotericpig
asked this question in
Q&A
-
I'd like to release my game in WebAssembly. However, if the user is in a mobile browser, I'd like to add some buttons for them to press at the bottom for turning left/right, but I'm not sure how to detect this in Ebiten. |
Beta Was this translation helpful? Give feedback.
Answered by
hajimehoshi
Jan 21, 2025
Replies: 1 comment 1 reply
-
var isMobile = false
func init() {
ua := js.Global().Get("navigator").Get("userAgent").String()
isMobile = strings.Contains(ua, "Android") || strings.Contains(ua, "iPhone") || strings.Contains(ua, "iPad") || strings.Contains(ua, "iPod")
} This should work in 99.99% cases. |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
esotericpig
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This should work in 99.99% cases.