|
If you're new to Python A VPython tutorial Pictures of 3D objects Choose a 3D object: Work with 3D objects: Windows, Events, & Files: What's new in Visual 5 VPython web site |
Keyboard InteractionsIf scene.kb.keys is nonzero, one or more keyboard events have been stored, waiting to be processed. Executing key = scene.kb.getkey() obtains a keyboard input and removes it from the input queue. If there are no events waiting to be processed, getkey() waits until a key is pressed. If len(key) == 1, the input is a single printable character such as 'b' or 'B' or new line ('\n') or tab ('\t'). Otherwise key is a multicharacter string such as 'escape' or 'backspace' or 'f3'. For such inputs, the ctrl, alt, and shift keys are prepended to the key name. For example, if you hold down the shift key and press F3, key will be the character string 'shift+f3', which you can test for explicitly. If you hold down all three modifier keys, you get 'ctrl+alt+shift+f3'; the order is always ctrl, alt, shift. Multicharacter names include delete, backspace, page up, page down, home, end, left, up, right, down, numlock, scrlock, f1, f2, f3, f4, f5, f6, f7, f8. Windows and Linux also have f9, f11, f12, insert. Here is a test routine that lets you type text into a label: from visual import * Note that mouse events also provide information about the ctrl, alt, and shift keys, which may be used to modify mouse actions.
|
||