Anyone got or knows an onscreen virtual keyboard?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Anyone got or knows an onscreen virtual keyboard?

Post by togFox »

I'm developing for PC (not tablet/mobile) and would like to use a virtual keyboard for the player to enter their name and save game file names etc but a google search fill the results with love.keyboard.

Anyone got a lib or know of one that will work without me coding my own? Really just looking for 26 letters. Even numbers are optional but nice. Not looking for bling. Thanks.
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
glitchapp
Party member
Posts: 253
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Anyone got or knows an onscreen virtual keyboard?

Post by glitchapp »

togFox wrote: Tue Jun 11, 2024 10:49 am I'm developing for PC (not tablet/mobile) and would like to use a virtual keyboard for the player to enter their name and save game file names etc but a google search fill the results with love.keyboard.

Anyone got a lib or know of one that will work without me coding my own? Really just looking for 26 letters. Even numbers are optional but nice. Not looking for bling. Thanks.
yes, here you are: https://codeberg.org/glitchapp/love2d-code-editor

I have other layouts like this here: https://codeberg.org/glitchapp/love-QWERTY-mobile
and this one may be better for big screens: https://codeberg.org/glitchapp/love-QWERTY

Feel free to fork them and I hope you find them useful.
* It doesn't matter if you plan to use it on desktop or touch devices, they work on both, all you need to do is to adjust the size and space of the keys and disable the touch functions if you don't need them
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Anyone got or knows an onscreen virtual keyboard?

Post by togFox »

Will it be easy to extract just the keyboard to use in my game or is it all tangled up with the editor?
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
glitchapp
Party member
Posts: 253
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Anyone got or knows an onscreen virtual keyboard?

Post by glitchapp »

As you said you want to use it on a desktop I guess you prefer the big one, I attached it here.
There's nothing else apart from the keyboard in this love game.

to retrieve the pressed key there is this code in the love.update function:

Code: Select all

if selectedKey then
            print("Selected Key:", selectedKey)
        end
so the variable selectedKey retrieves the keys you press on the touch keyboard.

The position, size of the keyboard and keys, space between keys etc you can tweak from this file:
https://codeberg.org/glitchapp/love-QWE ... yboard.lua

Code: Select all

-- Define the position and size of the keyboard
--keyboardX = 50
--keyboardY = 100
keyWidth = 150
keyHeight = 150
keyPadding = 2
Beware that I declared those variable twice, remove one of them.

Any question you have feel free to ask.
Attachments
love-QWERTY.love
(630.26 KiB) Downloaded 31 times
User avatar
togFox
Party member
Posts: 828
Joined: Sat Jan 30, 2021 9:46 am
Location: Brisbane, Oztralia

Re: Anyone got or knows an onscreen virtual keyboard?

Post by togFox »

Thanks. I forked and made a pull request. Feel free to decline if you don't have the time or interest to review my PR. :)
Last project:
https://togfox.itch.io/hwarang
A card game that brings sword fighting to life.
Current project:
Turn-based PBEM horse stable (racing) management sim: https://togfox.itch.io/horse-stable-manager
https://discord.gg/HeHgwE5nsZ
glitchapp
Party member
Posts: 253
Joined: Tue Oct 05, 2021 10:34 am
Contact:

Re: Anyone got or knows an onscreen virtual keyboard?

Post by glitchapp »

I accepted it and restored the resolution because without resizing the keyboard is partially out of the screen, there are two branches now: one with your resolution and one with the original one which keeps all the keyboard visible.
I'm ok with your changes, I usually separate the drawing functions on different files to keep everything modular but I'm fine with putting all the keyboard together.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests