Jacob Kruger wrote:
> Off-hand, while those 2 functions seem to work with other keystrokes, I'm 
> just wondering how, in a command line interface, I could capture things like 
> cursor keystrokes, and, would also be nice if there was a simple way to do it 
> that would work more cross platform, as opposed to only working on windows as 
> such?

This has NEVER been easy to do in a cross-platform way, in ANY
programming language.  It's not even easy to do in a non-cross-platform
way.  A big part of the problem is that, even on a single operating
system, there is no universally accepted definition for the character
code for "cursor up".  Unix and Linux have traditionally used the
"curses" library to abstract all of that.  Curses uses the terminfo
library, which contains definitions for hundreds (maybe thousands) of
terminals and terminal emulations.

Curses has never been big on Windows, in part because in Windows it is
easier just to convert to a GUI application.

> If I use either of them, it seems to return a string value that when ord() 
> it, it comes back as 224 for, for example, the up arrow keystroke - but when 
> you then map that to a character using chr(), it returns as the letter h, and 
> this is the same value for all four cursor/arrow keystrokes.

On Windows, the non-ASCII keys generate two-byte keycodes.  That 224 is
an "escape code" indicator that tells you you need to read another byte
to get the scan code for the key that was pressed.  Up arrow returns
0xE0 and 0x48.  Down arrow returns 0xE0 and 0x50.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to