So i am using python inside an ubntu and what i am doing is reading frame data from a game which i am playing in realtime (for genrating traning data for ML) and for each frame i capture in realtime (from the game screen) i want to know weather any keyboard key is pressed or not and finally which one and if no key is pressed i should get a clear indication for that as well.
NOTE: My program is running in a seprate window while i'll be playing in some other window.
I want a function like:
z=get_current_key_input(event)
if z == None: #This may cause warning form the warnings module
print 'No key is pressed for this frame move on to the next.'
else:
print str(z.key_code),'key is pressed for this frame.'
I can provide you with the code but it's messy and has cv2 and few more painful dependencies , so i think i'll provide it on demand.
All i am getting through googling is a function that gets called everytime i press a key but it's asyncronous and causes delays and so, the traning data i genrate using that is crap as hell.
[UPDATE]:
I have found a quiet promising function through intense search but can't actually work my way around it's complex usage and painful documentation. If anyone can understands how to work these documentations then it would be a great help to me. link to that function :here!