Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!jarthur!nntp-server.caltech.edu!eql.caltech.edu!rankin From: rankin@eql.caltech.edu Newsgroups: comp.lang.c Subject: Re: how do I trap a single keystroke in VMS C? Message-ID: <1990Jul25.191734.1@eql.caltech.edu> Date: 26 Jul 90 03:17:34 GMT References: <1990Jul25.085526.1@vaxr.llnl.gov> Sender: news@laguna.ccsf.caltech.edu Organization: Environmental Quality Laboratory, Caltech Lines: 26 In article <1990Jul25.085526.1@vaxr.llnl.gov>, andersen@vaxr.llnl.gov writes: > Does anybody have code written to trap a single keystroke in VMS C? I know I > need to use a QIO, and with enough dinking I could figure it out, but if I > can steal somebody elses solution I'd much rather. I need my code to respond > to a keystroke without having to also hit RETURN. (In OS-9 C, a > read( 0, &ch, 1) does the trick, but not in VMS.) This isn't really a C question; you'd get more of a response from comp.os.vms. $QIO is not difficult to use, but if you want to take the simplest route, use SMG$READ_KEYSTROKE. It handles the $QIO details and also performs multi-byte escape sequence recognition (into an unsigned short) for arrow and function keys. #include /* extended key codes */ unsigned long kb, sts; unsigned short keycode; (void)SMG$CREATE_VIRTUAL_KEYBOARD(&kd); sts = SMG$READ_KEYSTROKE(&kd, &keycode); Normal keys result in that key's ascii value being placed into 'keycode'. Some control keys trigger out-of-band actions. You'll need to either use $QIO directly or place the terminal in VMS's equivalent of "raw" mode if you want full control of those. Pat Rankin, rankin@eql.caltech.edu