GLUTKEYBOARDFUNC(3)

πŸ“¦
version 3.8.0 Β· 2 versions
, in centos-stream 10, centos-stream 9, fedora 43, fedora 44, opensuse-leap 16.0

πŸ’– GLUTKEYBOARDFUNC(3) πŸ’–

okay bestie, welcome to the OpenGLUT input corner of the manual β€” this one is literally the page that tells you how to make your window actually hear you when you smash a key. it's giving main character energy for real. and yes, the manual name is GLUTKEYBOARDFUNC and it lives in the OpenGLUT - input library, so you already know what time it is. πŸŽ€


✨ LIBRARY ✨

OpenGLUT - input β€” that's the vibe check, bestie. input handling, no cap. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <openglut.h>

void
glutKeyboardFunc(void( * callback )( unsigned char key, int x, int y ));

🌸 PARAMETERS 🌸

  • callback β€” your lil client function, the one that's gonna get called whenever a keyboard event happens. you write it, OpenGLUT runs it. that's the deal. 🫢

✨ DESCRIPTION ✨

okay so here's the tea: this callback registration is how you handle traditional ASCII keyboard input. the general rule of thumb (and it's a good one) is that if a key has a common ASCII code, then OpenGLUT assigns that code to the key and calls the Keyboard callback with the ASCII code in the key parameter. easy peasy. 🌈

for other keys though? nope, you gotta use glutSpecialFunc(). and lowkey, not all keys can be reported by OpenGLUT at all. that's just the way it is, bestie. πŸ’€

as a convenience (and it IS convenient, obsessed), the mouse coordinates β€” relative to your window β€” are also returned. so you get the key and the mouse position, together. iconic. 🐭✨

and the big one: this callback is bound to the current window. periodt. πŸ’…


😭 CAVEATS 😭

this function is not very international-friendly. like, it's not multilingual. it's monolingual and it's fine with that. πŸ™ˆ
windows created via glutCreateMenuWindow() always cascade keyboard and mouse events to their parent. always. no exceptions. so if your events are showing up somewhere you didn't expect, that's why, bestie. πŸ’€

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole page, bestie!! go forth and register those callbacks. πŸ¦‹πŸ’–

source/version: OpenGLUT - input Β· date: UNDATED Β· footer vibe: UNTITLED() β€” yeah it's untitled and undated but it's still iconic, we don't judge. βœ¨πŸ’…πŸŽ€