DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Getting Key Press
In Pys60 1.2 there are 3 types for app.body, namely - Canvas - Text - Listbox They can recieve and process key press. In older versions, they all have a bind method:
event codes are defined in key_codes module You can import some or all of them
from key_codes import EKeyLeftArrow, EKeySelect, EKey9, EKeyEdit
See <a href=http://www.flickr.com/photos/korakot/69980686/>diagram </a>for 6630. In the latest version, Canvas gains ability to respond to events in more details. You can give it 2 callbacks when creating a Canvas object.
c = Canvas(redraw_callback=None, event_callback=None)
event_callback will get a dict of the key event containing: - 'type': one of EEventKeyDown, EEventKey, or EEventKeyUp - 'keycode': the logical key - 'scancode': the physical key - 'modifier': probably about Shift, Ctrl ? The simplest use is to detect when type=EEventKey and use the 'keycode' value. For advanced use, look at keyviewer.py example.