Path: csiph.com!feeder.erje.net!2.eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c Subject: Re: Correct way to detect F1 Date: Mon, 29 Jan 2018 09:24:52 -0800 Organization: None to speak of Lines: 25 Message-ID: References: <800430537@f122.n1.z21.fsxnet> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="851279058270e854610aefc6c1465d1e"; logging-data="19390"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18fwL41Zb87eemaUqpbnkVe" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:lN4wg/OuhN5APXCm/sZUFg72NtY= sha1:9YYhuCPnaWKnNTkvS2gFWTgyV2k= Xref: csiph.com comp.lang.c:125954 Lorinczy Zsigmond writes: > On 2018-01-28 16:44, shinobi wrote: >> I wonder. What's the correct way to detect F1 in Linux Console? > > It would be getch of ncurses > https://linux.die.net/man/3/getch > https://linux.die.net/man/3/keypad ncurses, at least in normal use, takes over the terminal screen. That's fine for something like a text editor or file viewer, but it's overkill for a program that just wants to detect F1 on input. The sequence sent by F1 can vary depending on what kind of terminal you're using, though (almost?) all terminal emulators these days use VT100-like sequences by default. There's probably a clean way to handle function keys on UNIX-like systems without resorting to ncurses. comp.unix.programmer would be a good place to ask. -- Keith Thompson (The_Other_Keith) kst-u@mib.org Working, but not speaking, for JetHead Development, Inc. "We must do something. This is something. Therefore, we must do this." -- Antony Jay and Jonathan Lynn, "Yes Minister"