Reference for get_name (Keyboard)
Get the name of a key. This is part of the reference section.
Arc
Buffer
Data
Dialog
Ellipse
Geo Utils
Image
Joystick (future)
Keyboard
get_name (Keyboard)
Line
Mouse / Touchscreen
Pixel
Rectangle
Renderers
Shape
Sound (future)
Style
System
Text
Transform
Purpose
Get a string describing a key. Note the following values for special keys are maintained formally:
Alphanumeric keys will have their literal value like the a key will be 'a' in get_name. Other keys will have a best effort value like the minus key ('-') will be reported as 'minus' in get_name.
Name | Value | Constant |
---|---|---|
Alt | 'alt' | sketchingpy.const.KEYBOARD_ALT_BUTTON |
Arrow: Left Key | 'left' | sketchingpy.const.KEYBOARD_LEFT_BUTTON |
Arrow: Up Key | 'up' | sketchingpy.const.KEYBOARD_UP_BUTTON |
Arrow: Right Key | 'right' | sketchingpy.const.KEYBOARD_RIGHT_BUTTON |
Arrow: Down Key | 'down' | sketchingpy.const.KEYBOARD_DOWN_BUTTON |
Ctrl | 'ctrl' | sketchingpy.const.KEYBOARD_CTRL_BUTTON |
Shift | 'shift' | sketchingpy.const.KEYBOARD_SHIFT_BUTTON |
Space | 'space' | sketchingpy.const.KEYBOARD_SPACE_BUTTON |
Super | 'super' | sketchingpy.const.KEYBOARD_SUPER_BUTTON |
Tab | 'tab' | sketchingpy.const.KEYBOARD_TAB_BUTTON |
Snippet
Get a key currently pressed.
buttons = sketch.get_keyboard().get_keys_pressed() if len(buttons) > 0: print(buttons[0].get_name())
Examples
Availability
Available for Sketch2DApp and Sketch2DWeb. Note that, on web, some keys may be intercepted by the operating system like the ctrl key and may not be available to the sketch.