random keypress bounce in a terminal

Discussion in 'Python' started by =?ISO-8859-2?Q?Istv=E1n?=, Oct 2, 2007.

  1. 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
     
    =?ISO-8859-2?Q?Istv=E1n?=, Oct 2, 2007
    #1
    1. Advertising

  2. 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.
     
    Bjoern Schliessmann, Oct 2, 2007
    #2
    1. Advertising

  3. 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
     
    =?ISO-8859-1?Q?Istv=E1n?=, Oct 3, 2007
    #3
  4. 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.
     
    Bjoern Schliessmann, Oct 3, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nils M. Lunde

    Bounce Email

    Nils M. Lunde, Jul 12, 2004, in forum: Perl
    Replies:
    1
    Views:
    625
    Nils M. Lunde
    Jul 12, 2004
  2. globalrev
    Replies:
    4
    Views:
    816
    Gabriel Genellina
    Apr 20, 2008
  3. gaurav kashyap
    Replies:
    3
    Views:
    6,725
    Paul Boddie
    Oct 31, 2008
  4. Steve
    Replies:
    2
    Views:
    977
    edicionsdigitals.com edicions digitals xarxa socia
    Dec 7, 2010
  5. VK
    Replies:
    15
    Views:
    1,324
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page