josephrocca / OpenCharacters

Simple little web interface for creating characters and chatting with them. It's basically a single HTML file - no server. Share characters using a link (character data is stored within the URL itself). All chat data is stored in your browser using IndexedDB. Currently supports OpenAI APIs and ~any Hugging Face model.
https://josephrocca.github.io/OpenCharacters
MIT License
364 stars 60 forks source link

Improve device detection #47

Closed portra400nc closed 1 year ago

portra400nc commented 1 year ago

Adds a function that checks the user agent string to determine if the device is mobile or not. Tablet users can now insert line breaks.

This might need some improvements as I'm not sure if this works on all devices.

josephrocca commented 1 year ago

Thanks! I didn't consider how this would work for tablets. I've attempted a more future-proof heuristic here:

https://github.com/josephrocca/OpenCharacters/blob/4b9f34c2997d52f634bc74321c61a1d1233fc392/index.html#L7348-L7358

It's not great, but until there's broader support for the VirtualKeyboard API, it seems like a reasonable approach. Let me know if there are any edge cases you find where it doesn't work (I don't have a tablet, so wasn't able to test this at all)