random keypress bounce in a terminal

  • Thread starter =?ISO-8859-2?Q?Istv=E1n?=
  • Start date
?

=?ISO-8859-2?Q?Istv=E1n?=

Hi all,
I'm a novice in the world of Python and to begin with something useful I
want to create a small tool for my microcontroller work. So I wrote a
binary file compare (called bfc). It is just a few lines and put here
with two sample files: http://www.evoran.hu/tmp
I have found a keypress handler and built into my program. 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?
Thanks for any help,
István
 
B

Bjoern Schliessmann

István said:
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.

Regards,


Björn
 
?

=?ISO-8859-1?Q?Istv=E1n?=

Bjoern Schliessmann írta:
István wrote:



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
 
B

Bjoern Schliessmann

István said:
Moreover, I would also state for others: the behavior of this code
is independent of the keyboard repeating rate.

Sure, it's not multiple keypresses but a sequence generated by the
VT code in the kernel.
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

Check what? What's impossible?

Regards,


Björn
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top