Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Get Numlock Status

by Mr_Person (Hermit)
on Jul 04, 2003 at 05:24 UTC ( #271401=perlquestion: print w/replies, xml ) Need Help??

Mr_Person has asked for the wisdom of the Perl Monks concerning the following question:

I'm writing a Perl program that will have all of its input come from a PS/2 keypad that has no Numlock light on it. Because Numlock can be turned on and off at the pad but there's no way to see, just by looking at the pad, what the status of Numlock is I would like like to have an on-screen indicator for this.

Is there any way with Perl to retrieve the status of Numlock and perhaps even get updates when it is turned on or off? I know I could run setleds every few seconds and parse the output from there, but that doesn't seem like a very clean solution and also wouldn't be able to update the screen right away when the key is pressed.

Replies are listed 'Best First'.
Re: Get Numlock Status
by belg4mit (Prior) on Jul 04, 2003 at 05:45 UTC
    Curses may let you see this, I haven't checked. You'll probably be wanting to use Curses anyways so you can manage your screen for things like your status bar.

    I'm not belgian but I play one on TV.

      Actually, my screen for output is a 2x20 Matrix Orbital VFD, so I don't think Curses will work too well for managing output, and I wasn't able to find anything on using it for input that would allow me get an event when Numlock is changed.
        I've looked into a bit further... The event is available to usermode apps as showkey detects it (I get keycode 69), however I was unable to getch() it. It may be terminal specific, and you might have better luck searching the web for relevant information than I did.

        I'm not belgian but I play one on TV.

Re: Get Numlock Status
by Aragorn (Curate) on Jul 04, 2003 at 07:44 UTC
    If you're running you program under X11, I think you could use X11::Keyboard.


Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://271401]
Approved by Thelonius
Front-paged by ehdonhon
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (4)
As of 2023-01-30 14:13 GMT
Find Nodes?
    Voting Booth?

    No recent polls found