From: Peter Billam on
In a small command-line app, e.g. running in an xterm or a
linux console, I need to get at the keydown and keyup events.

( I realise this is impossible with a vt100 over a
serial line, and hence presumably with /dev/tty. )

I don't really want to have to use a whole GUI infrastructure
and do something like start up an invisible transparent window
overlaying the xterm - plus that wouldn't work on a linux console.

Is there any way ?

Regards, Peter

--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html
From: Alan Curry on
In article <slrnhlhubu.3mc.peter(a)box8.pjb.com.au>,
Peter Billam <contact.html(a)www.pjb.com.au> wrote:
>In a small command-line app, e.g. running in an xterm or a
>linux console, I need to get at the keydown and keyup events.

On a VC (i.e. /dev/tty1 through /dev/tty63) you can put the keyboard into
raw (scancode) or medium-raw (keycode) mode with the KDSKBMODE ioctl. See
console_ioctl(4). It shouldn't take much to make that work from perl.

Just beware of leaving the keyboard in that state when your program exits -
that makes the console pretty hard to use. (If that happens, SysRq+R can get
out of it.)

>
>I don't really want to have to use a whole GUI infrastructure
>and do something like start up an invisible transparent window
>overlaying the xterm - plus that wouldn't work on a linux console.
>
>Is there any way ?

The xterm case will probably be harder.

--
Alan Curry
From: Peter Billam on
On 2010-01-22, Alan Curry <pacman(a)kosh.dhis.org> wrote:
> In article <slrnhlhubu.3mc.peter(a)box8.pjb.com.au>,
> Peter Billam <contact.html(a)www.pjb.com.au> wrote:
>>In a small command-line app, e.g. running in an xterm or a
>>linux console, I need to get at the keydown and keyup events.
>
> On a VC (i.e. /dev/tty1 through /dev/tty63) you can put the keyboard
> into raw (scancode) or medium-raw (keycode) mode with the KDSKBMODE
> ioctl. Seeconsole_ioctl(4). It shouldn't take much to make that
> work from perl. ... The xterm case will probably be harder.

It didn't take long to give up the idea of kbd-event-handling from
the command-line :-) I thought about doing it as CGI/JavaScript,
but ended up just making it a _monophonic_ keyboard and reading
bytes from STDIN. Now in its first production version ...
http://www.pjb.com.au/midi/index.html
http://www.pjb.com.au/midi/midikbd.html

Thanks for help, Regards, Peter

--
Peter Billam www.pjb.com.au www.pjb.com.au/comp/contact.html