ord() to catch Arrow Key press on Linux and Mac -- Python -
how use ord() catch arrow key press in mac , linux? know can use msvcrt in windows. don't have character associated them.
are talking in console?
i have hacky solution if want avoid msvcrt.
value = raw_input("hit left arrow key enter: ") print ord(value[0]), ord(value[1]), ord(value[2]) if ord(value[0]) == 27 , ord(value[1]) == 91 , ord(value[2]) == 68: print "you hit left key!" elif ord(value[0]) == 27 , ord(value[1]) == 91 , ord(value[2]) == 67: print "you hit right key!"
this written illustrate how it's done. can condense more consice system depending on need. can use ord -- need remember it's multi-character string need analyze character character.
Comments
Post a Comment