Can love2D detect keypresses when unfocused?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Connorses
Citizen
Posts: 53
Joined: Fri Sep 06, 2013 7:02 am

Can love2D detect keypresses when unfocused?

Post by Connorses »

I would like to press a key and have my love2D program respond without me first focusing the love2D window by clicking it. Would be useful for, say, a livestream visual that I can alter with a key press.
User avatar
BrotSagtMist
Citizen
Posts: 62
Joined: Fri Aug 06, 2021 10:30 pm

Re: Can love2D detect keypresses when unfocused?

Post by BrotSagtMist »

Doesnt look like it.
If youre the only user a quick hack in would be to just read from /dev/input in a thread.
I am not aware of other simple ways, let alone one that universally works.
obey
User avatar
zorg
Party member
Posts: 3145
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Can love2D detect keypresses when unfocused?

Post by zorg »

While keyboard and mouse won't really work like that, you can try whether gamepad input works when unfocused, that has a higher chance i think.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
grump
Party member
Posts: 813
Joined: Sat Jul 22, 2017 7:43 pm

Re: Can love2D detect keypresses when unfocused?

Post by grump »

There's always the option to poll the keyboard through FFI, but that's OS-specific. For example, on Windows you can import and call GetAsyncKeyState to query the state of a key.
Post Reply

Who is online

Users browsing this forum: entua, MrFariator and 47 guests