Raspberry Pi Zero W Into a Wireless USB Keyboard HID. Part 5 Python Keyboard Input

Published: 22 December 2020
on channel: ZeroLife
302
5

def interpret():
typing = True

action_key = {'\ENTER':40,'\ESCAPE':41,'\DELETE':42,'\TAB':43,'\SPACE':44,'\PRINT':70,'\SCROLL':71,'\PAUSE':72,'\INSERT':73,'\HOME':74,'\PAGEUP':75,'\END':77,'\PAGEDOWN':78,'\RIGHTARROW':79,'\LEFTARROW':80,'\DOWNARROW':81,r'\UPARROW':82,'\POWER':102,'\LEFTCTRL':224,'\LEFTSHIFT':225,'\LEFTALT':226,'\LEFTGUI':227,'\RIGHTCTRL':228,'\RIGHTSHIFT':229,'\RIGHTALT':230,'\RIGHTGUI':231}
function_key = {'\F1':58,'\F2':59,'\F3':60,'\F4':61,'\F5':62,'\F6':63,'\F7':64,'\F8':65,'\F9':66,'\F10':67,'\F11':68,'\F12':69,'\F13':104,'\F14':105,'\F15':106,'\F16':107,'\F17':108,'\F18':109,'\F19':110,'\F20':111,'\F21':112,'\F22':113,'\F23':114,'\F24':115}
menu_key = {'\EXECUTE':116,'\HELP':117,'\MENU':118,'\SELECT':119,'\STOP':120,'\AGAIN':121,r'\UNDO':122,'\CUT':123,'\COPY':124,'\PASTE':125,'\FIND':126,'\MUTE':127,'\VOLUP':128,'\VOLDOWN':129,'\CAPLOCK':130,r'\NUMLOCK':131,'\SCROLLLOCk':132}
#mod_key = {'\LEFTCTRL':1,'\LEFTSHIFT':2,'\LEFTALT':4,'\LEFTWIN':8,'\RIGHTCTRL':16,'\RIGHTSHIFT':32,'\RIGHTALT':64,'\RIGHTWIN':128}

merged_key = {}
merged_key.update(action_key)
merged_key.update(function_key)
merged_key.update(menu_key)

while typing:
word = input('~~#:')

if word =='exit()':
typing = False
elif word in merged_key:
write_report(NULL_CHAR*2+chr(merged_key[word])+NULL_CHAR*5)
elif word[:6] == '\SLEEP':
time.sleep(int(word[6:]))
else:
translate(word)
write_report(NULL_CHAR*8)

if _name_ == '__main__':
interpret()


PAT:   / rezatahirkheli  
PP: https://www.paypal.com/paypalme/rezat...
BTC: 3EUQBWZKX9Vcwdffd3cUGATQopxrAQQxJ9
LTC: MBXE6hJgxxFYSD8SjmR7sHCHGTqFXmNGoU
GFM: https://gofund.me/7d6500bd


Watch video Raspberry Pi Zero W Into a Wireless USB Keyboard HID. Part 5 Python Keyboard Input online without registration, duration hours minute second in high quality. This video was added by user ZeroLife 22 December 2020, don't forget to share it with your friends and acquaintances, it has been viewed on our site 302 once and liked it 5 people.