random keypress bounce in a terminal

István uhum2004 at freemail.hu
Wed Oct 3 04:01:12 EDT 2007


Bjoern Schliessmann írta:
> István wrote:
>
>   
>> It works fine as long as I hit keys normally, but gives extra
>> characterts if I keep pressing some key, e.g. up or down arrow
>> keys. It runs on a Linux system. What's the wrong with it?
>>     
>
> Nothing. Linux VTs will generate multiple characters for special
> keys.
>   
I know it and I do handle it:
   ch = sys.stdin.read(1)
   if (ord(ch)==27):
    chstr=ch
    chstr+=sys.stdin.read(1)
    chstr+=sys.stdin.read(1)
   else:
    chstr=ch
Moreover, I would also state for others: the behavior of this code is 
independent of the keyboard repeating rate.
But what if it _seems_  to work differently...?
That's the reason of trying to make somebody just to see him/herself the 
symptom.
*   bfc.py 4863 bytes <http://evoran.hu/tmp/bfc.py>*
*  uni_getch.py 873 bytes <http://evoran.hu/tmp/uni_getch.py>*
*   demo1.brd 84311 bytes <http://evoran.hu/tmp/demo1.brd>*
*   demo2.brd 84336 bytes <http://evoran.hu/tmp/demo2.brd>
http://www.evoran.hu/tmp/
*Please, check somebody and explain how is possible what is impossible....
Istvan



More information about the Python-list mailing list