Python (3.6.1) keypress detection and popups -


im kinda new python , tried printing key when pressed on windows , show key in popup message:

import msvcrt import ctypes  # included library python install.  def mbox(title, text, style):     ctypes.windll.user32.messageboxw(0, text, title, style)  while true:     if msvcrt.kbhit()== true:         key = msvcrt.getch()         print(key)  # show result         mbox(key, key, 1) 

and problems are:

1) output if press key diffrent, example :"a" "b'a'" why? , how can change "a"? (the output on popup weirder : 1x when press 1 or 2*x when press 2)

2) while true: makes code run time, , keeps detecting if key has been pressed?

3) there lib python detects key-press windows , linux altogether?

thank's alot.

ok found answers:

1) msvcrt.getwch() wide char variant of getch(), returning unicode value.

read more at: https://docs.python.org/3.6/library/msvcrt.html

2) guess yes, if can confirm ill glad.

3) not know, there diff libs each op system (again if im wrong please leave note here).


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -