KEYBOARD(3)
okay so bestie, welcome to KEYBOARD(3) from the Library Functions Manual π this is the keyboard-control page, and itβs giving multi-threaded character-at-a-time realness. letβs go.
π NAME π
initkeyboard, ctlkeyboard, closekeyboard β keyboard control, and thatβs the whole name section, no cap.
β¨ SYNOPSIS β¨
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <keyboard.h>
Keyboardctl *initkeyboard(char *file)
int ctlkeyboard(Keyboardctl *kc, char *msg)
void closekeyboard(Keyboard *kc)
π DESCRIPTION π
okay so the whole vibe: these functions access and control a keyboard interface for character-at-a-time I/O in a multi-threaded environment, usually in combination with mouse(3). They use the message-passing Channel interface in the threads library (see thread(3)); programs that wish a more event-driven, single-threaded approach should use event(3). slay.
initkeyboard opens a connection to the keyboard and returns a Keyboardctl structure β say hi:
typedef struct Keyboardct Keyboardctl;
struct Keyboardctl
{
Channel *c; /* chan(Rune[20]) */
char *file;
int consfd; /* to cons file */
int ctlfd; /* to ctl file */
int pid; /* of slave proc */
};
The argument to initkeyboard is ignored (on Plan 9, it is the name of the keyboard device). iykyk.
Once the Keyboardctl is set up a message containing a Rune will be sent on the Channel Keyboardctl.c to report each character read from the device. literally each character, one at a time, main character energy.
ctlkeyboard is used to set the state of the interface, typically to turn raw mode on and off. It writes the string msg to the control file associated with the device, which is assumed to be the regular device file name with the string ctl appended. thatβs the whole assignment, bestie.
closekeyboard closes the file descriptors associated with the keyboard, kills the slave processes, and frees the Keyboardctl structure. cleanup queen behavior β¨.
π SOURCE π
/src/libdraw
π¦ SEE ALSO π¦
π BUGS π
β οΈ Because the interface delivers complete runes, there is no way to report lesser actions such as shift keys or even individual bytes. thatβs the tea: no shift-key side quests, no single-byte crumbs. periodt.
okay bye bestie β this was KEYBOARD(3) from the Library Functions Manual, source /src/libdraw, and the footer is literally just KEYBOARD(3) with no extra version/date drama π
β¨
π¦ where this page comes from
- alpine 3.24: plan9port-doc 0_git20260208-r0 Β· LPL-1.02
- arch rolling: plan9port 20261021-2 Β· custom
- nixos 26.05: plan9port 0-unstable-2025-11-10
- nixos 26.05: plan9port-wayland 0-unstable-2025-11-26
- nixpkgs unstable: plan9port 0-unstable-2025-11-10
- nixpkgs unstable: plan9port-wayland 0-unstable-2025-11-26
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms