key or mouse input with hold
Posted: Mon Oct 25, 2021 3:37 pm
Hi, does anyone know a (preferably lightweight) lib for mouse/keyboard input that can do the following:
Assume my player can cast an ability, say throw a fireball. To do so, the user can press the 'q' key.
He can also hold down the 'q' key to charge the fireball before throwing it so that it gains more damage or size etc.
I am looking for a lib that can differentiate between 'q' is briefly pressed - fire immediately and 'q' is hold - do NOT fire immediately, wait for the user to release 'q' to throw a charged fireball.
Yes, I am aware that there are libraries that let me use "press" and "hold" events, but I have not found one that does NOT fire the "press" event when only the "hold" event should be triggered. While searching I inspected "boipushy" and "lynput" which have some cool features and are fairly simple, but sadly do not solve the described problem.
In case I did not made the problem clear enough, just let me know and I will upload a simple love file to showcase what I mean*.
And yes, I am aware that I could change the charging mechanism to not have the described problem, but I am hooked already - so either I find a lib or I will code it myself
* if you know the Witcher 3 - the same principle applies to Quen and alternate Quen sign for instance. Briefly press button = cast Quen (passive) but hold button = cast active Quen sign.
Assume my player can cast an ability, say throw a fireball. To do so, the user can press the 'q' key.
He can also hold down the 'q' key to charge the fireball before throwing it so that it gains more damage or size etc.
I am looking for a lib that can differentiate between 'q' is briefly pressed - fire immediately and 'q' is hold - do NOT fire immediately, wait for the user to release 'q' to throw a charged fireball.
Yes, I am aware that there are libraries that let me use "press" and "hold" events, but I have not found one that does NOT fire the "press" event when only the "hold" event should be triggered. While searching I inspected "boipushy" and "lynput" which have some cool features and are fairly simple, but sadly do not solve the described problem.
In case I did not made the problem clear enough, just let me know and I will upload a simple love file to showcase what I mean*.
And yes, I am aware that I could change the charging mechanism to not have the described problem, but I am hooked already - so either I find a lib or I will code it myself
* if you know the Witcher 3 - the same principle applies to Quen and alternate Quen sign for instance. Briefly press button = cast Quen (passive) but hold button = cast active Quen sign.