Documentation
¶
Overview ¶
Package termmod is the native module "term": the terminal a key at a time, and its size (TODO.md Q99), for programs that draw the screen themselves with ANSI escape codes, such as examples/vi.kkl.
use term;
main() {
term::raw(fn() {
for (local k = term::key(); k != "q"; k = term::key()) print(k, " ");
});
}
A key is the character typed ("a", "é", " ") or the name of a key, two or more letters: "Enter", "Tab", "Backspace", "Esc", "Up", "Down", "Left", "Right", "Home", "End", "PageUp", "PageDown", "Insert", "Delete", "F1".."F12", "Ctrl-A".."Ctrl-Z", with "Ctrl-", "Alt-" and "Shift-" before the keys a terminal sends them with ("Ctrl-Left", "Shift-Tab").
Keys come from the program's standard input, also when it is not a terminal (a pipe, a file: tests write the keys there). Only kukel run and exec give a program the terminal itself (native.SetTerminal): an interpreter of a Go program reads its standard input as it is, and raw changes nothing.