Guest User

Untitled

a guest
Nov 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import curses
  2.  
  3. def main(win):
  4. win.nodelay(True)
  5. key = ''
  6. record = ''
  7. win.clear()
  8. win.addstr("Key:")
  9. win.addstr('nnRecord:')
  10. win.addstr(record)
  11. while True:
  12. try:
  13. key = win.getkey()
  14.  
  15. if str(key) == '^?':
  16. # Attempt at detecting the Backspace key
  17. record = record[:-1]
  18.  
  19. elif str(key) == 'n':
  20. # Attempt at detecting the Enter Key
  21. record = ''
  22.  
  23. else:
  24. record += str(key)
  25. win.clear()
  26. win.addstr("Key:")
  27. win.addstr(str(key))
  28. win.addstr('nnRecord:')
  29. win.addstr(record)
  30. if key == os.linesep:
  31. break
  32. except Exception as e:
  33. # No input
  34. pass
  35.  
  36. curses.wrapper(main)
  37. # CTRL+C to close the program
Add Comment
Please, Sign In to add comment