Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > How to scan Keyboard in Perl or else on Linux ?

Reply
Thread Tools

How to scan Keyboard in Perl or else on Linux ?

 
 
Raphaël
Guest
Posts: n/a
 
      11-04-2004
Hi,

On Linux, does somebody know how to get the keyboard status in Perl ?

I explane :
-> I would like to write a Perl script which scan the keyboard and
return the list of pressed keys.

For example, let "keyboard_scan()" be the name of this function, with
the following behavior:

- When keyboard_scan() is called, if the user is pressing no keys, I
would like keyboard_scan() to return the empty string "".
- When keyboard_scan() is called, if the user is pressing the CTRL key,
I would like keyboard_scan() to return the code string of the CTRL key.
- When keyboard_scan() is called, if the user is pressing the ALT key
and the SHIFT key, I would like the function to return the string
containing the code of the SHIFT key and the code of the ALT key.
etc ...

Or perhaps somebody knows how to do it in another language (C, TCL, ...) ?

Thanks !

Raphaël.
 
Reply With Quote
 
 
 
 
Måns Rullgård
Guest
Posts: n/a
 
      11-04-2004
Raphaël <(E-Mail Removed)> writes:

> Hi,
>
> On Linux, does somebody know how to get the keyboard status in Perl ?
>
> I explane :
> -> I would like to write a Perl script which scan the keyboard and
> return the list of pressed keys.
>
> For example, let "keyboard_scan()" be the name of this function, with
> the following behavior:
>
> - When keyboard_scan() is called, if the user is pressing no
> keys, I would like keyboard_scan() to return the empty string
> "".
> - When keyboard_scan() is called, if the user is pressing the
> CTRL key, I would like keyboard_scan() to return the code
> string of the CTRL key.
> - When keyboard_scan() is called, if the user is pressing the
> ALT key and the SHIFT key, I would like the function to return
> the string containing the code of the SHIFT key and the code
> of the ALT key.
> etc ...
>
> Or perhaps somebody knows how to do it in another language (C, TCL, ...) ?


Are you running under X? Look at the source of xkbwatch. It displays
the status of the modifier keys.

--
Måns Rullgård
http://www.velocityreviews.com/forums/(E-Mail Removed)
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      11-04-2004
Raphaël <(E-Mail Removed)> wrote:

> does somebody know how to get the keyboard status in Perl ?



Have you already seen the 3 Perl FAQs about keyboards?

perldoc -q keyboard

How can I read a single character from a file? From the keyboard?
How do I do fancy stuff with the keyboard/screen/mouse?
How do I check whether input is ready on the keyboard?


--
Tad McClellan SGML consulting
(E-Mail Removed) Perl programming
Fort Worth, Texas
 
Reply With Quote
 
Raphaël
Guest
Posts: n/a
 
      11-09-2004
Hi,

I didn't find what I needed even in the ReadKey CPAN package ... so I
finally followed the Måns advise even if it's not portable to none unix
platforms.

I checked how is done the xkbwatch source code and I wrote my own
procedure (mainly because I don't need the xkbwatch graphical interface).

Now I call it from my perl script and it works fine !

Thanks everybody,

Raphaël.

Måns Rullgård wrote:
> Raphaël <(E-Mail Removed)> writes:
>
>
>>Hi,
>>
>>On Linux, does somebody know how to get the keyboard status in Perl ?
>>
>>I explane :
>>-> I would like to write a Perl script which scan the keyboard and
>>return the list of pressed keys.
>>
>>For example, let "keyboard_scan()" be the name of this function, with
>>the following behavior:
>>
>> - When keyboard_scan() is called, if the user is pressing no
>> keys, I would like keyboard_scan() to return the empty string
>> "".
>> - When keyboard_scan() is called, if the user is pressing the
>> CTRL key, I would like keyboard_scan() to return the code
>> string of the CTRL key.
>> - When keyboard_scan() is called, if the user is pressing the
>> ALT key and the SHIFT key, I would like the function to return
>> the string containing the code of the SHIFT key and the code
>> of the ALT key.
>>etc ...
>>
>>Or perhaps somebody knows how to do it in another language (C, TCL, ...) ?

>
>
> Are you running under X? Look at the source of xkbwatch. It displays
> the status of the modifier keys.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Nikon Scan vs Vuescan, Nikon Scan smears detail, why (0/1) melbjer@hotmail.com Digital Photography 3 08-09-2008 02:52 AM
Best to scan in 48 Bit HDR? Or use 48 Bit + modify during scan? NewScanner Digital Photography 9 01-16-2007 04:07 AM
How to scan Keyboard in Perl or else on Linux ? =?ISO-8859-1?Q?Rapha=EBl?= Perl 2 11-09-2004 03:28 PM
Progressive scan dvd's on a non-progressive scan tv jack lift DVD Video 7 12-09-2003 06:01 PM



Advertisments