[Tutor] Need to be able to accept Page Down or CTRL-E
Steven D'Aprano
steve at pearwood.info
Sat Feb 2 00:24:49 CET 2013
On 01/02/13 23:38, Dave Angel wrote:
> On 02/01/2013 03:34 AM, Alan Gauld wrote:
>>
>> <snip>
>>
>> OTOH if you mean you want to send the page up/down/arrows as the
>> "something" then its a different game and you can do it. In that case
>> you need todo what you did with ESC. The character set your external app
>> uses will determine the codes you send. Assuming its the same set as
>> your local setup you can use the following program(untested!) to read
>> the codes from your keyboard (assuming you are on Windows):
>>
>> import msvcrt
>>
>> print "Hit space to end..."
>> print
>>
>> while True:
>> ky = msvcrt.getch()
>
> The OP is running Python 2.73 on Linux.
You can use getch under Linux.
http://code.activestate.com/recipes/577977/
Using that recipe, I see that PageUp sends the following four bytes:
'\x1b[5~'
PageDown also sends four bytes:
'\x1b[6~'
and Ctrl-E sends a single byte:
'\x05'
--
Steven
More information about the Tutor
mailing list