GetAsyncKeyState Mac/Linux API Equivalents

Can anyone share or point me in the direction of some code which shows how you can perform the equivalent of the Windows GetAsyncKeyState API call on Mac and Linux?

P.S. I’m aware there is a Keyboard module built into Xojo already, however this is only available on Desktop and I need to be able to detect this within a console app.