magmax / python-readchar

Python library to read characters and key strokes
MIT License
143 stars 45 forks source link

Fix Up arrow and most F keys, etc. #22

Closed suresttexas00 closed 7 years ago

suresttexas00 commented 7 years ago

Per my other message, https://github.com/magmax/python-readchar/issues/20#issuecomment-286588396

1 way was the best I can manage for now!

This works (but I am not sure I need to have the `\x4f\ now since that is not actually part of the F key codes. (at least not on linux?)

EDIT: removed the \x4f\ checking too.. 2ND EDIT: re-added the \x4f\ for F1-F4.

suresttexas00 commented 7 years ago

When I enable the the print statement in readchar_linux.py; I get this for Delete:

('\x1b', '0x1b')
('[', '0x5b')
('3', '0x33')
('~', '0x7e')

I get this for Backspace:

('\x7f', '0x7f')

Since delete key and backspace keys do different things, they cannot be the same code.

I don't have a key labeled "SUPR", so I don't know what it is.

suresttexas00 commented 7 years ago

I created this little interactive tester for use in reading what keys produce:

# -*- coding: utf-8 -*-

import readchar

while True:

    x = readchar.readkey()
    if x == readchar.key.F5:
        print("terminated.")
        break
    print("key read len was: %s" % len(x))
    if x == readchar.key.INSERT:
        print(" key")
suresttexas00 commented 7 years ago

I also removed the Danny Yoo attribution in the Key.py file.

suresttexas00 commented 7 years ago

This is correct because on English keyboards there is no such key as SUPR ... our keyboards it is DELETE and is not the same as Backspace... https://www.pcreview.co.uk/threads/spanish-keyboard.2840896/

One of my keyboards: img_8402

asdfgj<-backspace deletes these \<cursor> Delete deletes these->klzxcvbnm

suresttexas00 commented 7 years ago

My only concern in all this is does it still work in windows. Does the travis test for windows?

suresttexas00 commented 7 years ago

I am going to close this and do a re-pull for clarity. I have a new solution that also works for all Linux keys, including the pesky ESC key. I also implements a version of @guiweber windows code, although it tries to use the Linux type constants in our key.py file versus the string Windows names.