Get just one char from long keypress python curses [accepted] -


hi i'm writing program in python curses , need 1 char long keypress. (in other words need if keep pressing down key program has char function getchar() once). need because want prevent curses refreshing many times windows. i'm not giving code cause in italian , long. thank you.

one solves problem by

  1. setting variable record fact character read
  2. reading character
  3. if no character available (within timeout, instance), stop reading
  4. if no character read yet, record fact 1 read (as remembering character)
  5. go step 2, read again

simply reading terminal not cause curses work (it refresh on each read, anyway). have work if program modifies screen. (assuming have turned echo off), there no need worry number of calls refresh.

regarding comment "it has clear , refresh box": there choices (per documentation):

avoid using window.clear() unless intend repainting whole window, because slower, , visually distracting.

by way, curses function called getch, not getchar. latter may not work curses.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -