Python Forum
keyboad scanner routine(linux and windows)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
keyboad scanner routine(linux and windows)
#1
I am a beginning python programmer and I also teach introductory python.
I (we) are looking for a keyboard scan routine to capture keyboard input without entering a return.
We use Linux as out main os.
I personally have used curses but I'm looking for a simple pythonic method to teach this skill.
QUESTIONS:
Is curses used a lot?
Can curses be used with MS Windows?
What are some simple alternatives?

Thank you,
1885

example I've used :
import curses
import os
def main(win):
    win.nodelay(True)
    key=""
    win.clear()                
    win.addstr("Detected key:")
    while 1:          
        try:                 
           key = win.getkey()         
           win.clear()                
           win.addstr("Detected key:")
           win.addstr(str(key)) 
           if key == os.linesep:
              break           
        except Exception as e:
           # No input   
           pass         

curses.wrapper(main)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Use Barcode Scanner With Python Extra 2 1,601 Jul-14-2022, 09:52 AM
Last Post: Gribouillis
  How to compile a Python script for a Windows / Linux executable? netanelst 2 1,327 May-24-2022, 07:02 AM
Last Post: netanelst
  Resources for printing tabledata-Linux and Windows hammer 4 1,426 Apr-25-2022, 12:09 PM
Last Post: hammer
  port scanner Than999 0 1,202 Feb-01-2022, 12:24 PM
Last Post: Than999
  Python BLE Scanner not detecting device alexanderDennisEnviro500 0 2,010 Aug-01-2021, 02:29 AM
Last Post: alexanderDennisEnviro500
  Did subprocess.Popen() causes main routine to pause stdout? liudr 4 3,636 May-04-2021, 08:58 PM
Last Post: liudr
  A dynamic link library (DLL) initialization routine failed ish93 0 1,780 Jan-11-2021, 08:22 PM
Last Post: ish93
  Windows Python Memory Scanner Awesometech 1 21,625 Oct-14-2020, 07:44 AM
Last Post: badengagen
  multiprocessing difference between Linux and Windows direl 2 2,643 Oct-01-2020, 07:10 PM
Last Post: direl
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,647 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020