Okay I just found an even better way after I stumbled upon the API of FlxG.keys:
@starry-abyss Yep, knew about that, but thank you anyway.
@Gama11 damn, it works!
Thanks <3! A lot of my students were having this problem and didn't know how to fix it.
Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.