glutKeyboardFunc

sets the keyboard callback for the current window.

Signature

glutKeyboardFunc( )-> void
glutKeyboardFunc( function )
Specify handler for GLUT 'Keyboard' events
    def handler( (int) key, (int) x, (int) y ):
        return None

Parameters

VariablesDescription
func
The new keyboard callback function.

Description

glutKeyboardFunc sets the keyboard callback for the current window. When a user types into the window, each key press generating an ASCII character will generate a keyboard callback. The key callback parameter is the generated ASCII character. The state of modifier keys such as Shift cannot be determined directly; their only effect will be on the returned ASCII data. The x and y callback parameters indicate the mouse location in window relative coordinates when the key was pressed. When a new window is created, no keyboard callback is initially registered, and ASCII key strokes in the window are ignored. Passing NULL to glutKeyboardFunc disables the generation of keyboard callbacks.
During a keyboard callback, glutGetModifiers may be called to determine the state of modifier keys when the keystroke generating the callback occurred.
Use glutSpecialFunc for a means to detect non-ASCII key strokes.

See Also

glutKeyboardUpFunc glutSpecialFunc glutCreateWindow glutMouseFunc glutSpaceballButtonFunc glutButtonBoxFunc glutTabletButtonFunc glutGetModifiers

Sample Code References

The following code samples have been found which appear to reference the functions described here. Take care that the code may be old, broken or not even use PyOpenGL.

glutKeyboardFunc
OpenGLContext OpenGLContext/glutcontext.py Lines: 90, 92
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson11.py Lines: 177
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson18.py Lines: 289
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6.py Lines: 215
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson41.py Lines: 349
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson16.py Lines: 198
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson23.py Lines: 258
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson5.py Lines: 227
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson4.py Lines: 179
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson26.py Lines: 244
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson12.py Lines: 178
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson3.py Lines: 156
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson13.py Lines: 209
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson1.py Lines: 129
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson19.py Lines: 270
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson42.py Lines: 419
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson2.py Lines: 151
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson6-multi.py Lines: 253
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson45.py Lines: 501
OpenGL-Demo PyOpenGL-Demo/NeHe/lesson48/NeHeGL.py Lines: 154
OpenGL-Demo PyOpenGL-Demo/da/dots.py Lines: 106
OpenGL-Demo PyOpenGL-Demo/GLUT/gears.py Lines: 273
OpenGL-Demo PyOpenGL-Demo/GLUT/shader_test.py Lines: 141
OpenGL-Demo PyOpenGL-Demo/GLUT/glutplane.py Lines: 221
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/conesave.py Lines: 55
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/checker.py Lines: 112
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/lorentz.py Lines: 119
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/arraytest.py Lines: 100
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/text.py Lines: 113
OpenGL-Demo PyOpenGL-Demo/GLUT/tom/cone.py Lines: 114
OpenGL-Demo PyOpenGL-Demo/redbook/scene.py Lines: 139
OpenGL-Demo PyOpenGL-Demo/redbook/drawf.py Lines: 112
OpenGL-Demo PyOpenGL-Demo/redbook/lines.py Lines: 141
OpenGL-Demo PyOpenGL-Demo/redbook/movelight.py Lines: 140
OpenGL-Demo PyOpenGL-Demo/redbook/smooth.py Lines: 106
OpenGL-Demo PyOpenGL-Demo/redbook/fog.py Lines: 154
OpenGL-Demo PyOpenGL-Demo/redbook/teapots.py Lines: 206
OpenGL-Demo PyOpenGL-Demo/redbook/cube.py Lines: 98
OpenGL-Demo py2exe-example/shader_test.py Lines: 143
{Artistic License} PymmLib pymmlib/applications/glutviewer.py Lines: 408
{LGPL} PyUI2 renderers/openglGlut.py Lines: 61
{LGPL} PyUI2 system/glutdevice.py Lines: 58
{LGPL} PyMT pymt/ui/window/win_glut.py Lines: 16, 44
{GPL3} OpenGL-Programmable 05-shader.py Lines: 315
{GPL3} OpenGL-Programmable 07-attrib.py Lines: 334
{GPL3} OpenGL-Programmable 03-array.py Lines: 235
{GPL3} OpenGL-Programmable 09-gles2.py Lines: 377
{GPL3} OpenGL-Programmable 06-perpixel.py Lines: 323
{GPL3} OpenGL-Programmable 10-gl3.2core.py Lines: 387
{GPL3} OpenGL-Programmable 02-displaylist.py Lines: 233
{GPL3} OpenGL-Programmable 04-vbo.py Lines: 254
{GPL3} OpenGL-Programmable 01-direct.py Lines: 224
{GPL3} OpenGL-Programmable 08-pbo.py Lines: 356