473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

random keypress bounce in a terminal

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

Oct 2 '07 #1
3 1491
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.

Regards,
Björn

--
BOFH excuse #258:

That's easy to fix, but I can't be bothered.

Oct 2 '07 #2
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
Oct 3 '07 #3
István wrote:
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

--
BOFH excuse #120:

we just switched to FDDI.

Oct 3 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Trevor Fairchild | last post by:
I'm writing a program that is designed for quick navigation using specific buttons on the keyboard. In doing this, I have added a KeyPress event for every control on the form to intercept the key...
4
by: Bloon | last post by:
I have a question that how to debug a program only having .exe file. Is there any techniques or tools that can do that? Thanks a lot.
4
by: phil_gg04 | last post by:
Dear Javascript Experts, I'm currently implementing Anyterm, a terminal emulator on a web page. It consists of an Apache module, some XmlHTTP and a bit of Javascript. The idea is to give you...
7
by: Dave Hammond | last post by:
You'd think this was an occasionally asked question, but a search for previous related posts only turned up one from 1999, and that one was never anwered. So... When handling a keypress event,...
2
by: Phlip | last post by:
Newsgroupies: One myth about USENET is that each group has a charter; some "official" list of on-topic concepts. When a post arrives "violating" this myth, the replies that support the myth can...
7
by: hlubenow | last post by:
Hello, I'd like to check, if a single key is pressed on a Linux xterm. This code waits for a key to be pressed and returns the character: -------------------------------------------- ...
3
by: Lars Eighner | last post by:
The ncurses functions are such a mess (and some of it I suspect is in ncurses itself) that I am thinking the easiest way to write a terminal interface is simply to write ANSI directly to the...
0
by: UmeIsmail | last post by:
i am trying to implement GP , and have random initialization in arraylist , the code works fine in debug mode , but when i run it without debugging, all trees come out to be same , if i use message...
18
by: Grant Edwards | last post by:
Could whoever is responsible for the gateway that is grabbing my postings off of Usenet and e-mailing them out please fix the headers in the mail messages so that I don't get the bounce messages?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.