Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > catching ctrl chars

Reply
Thread Tools

catching ctrl chars

 
 
justme
Guest
Posts: n/a
 
      06-30-2004
hi

how can i catch Ctrl-x (or any other letters except 'c' ) in perl ??
thanks..
 
Reply With Quote
 
 
 
 
John Bokma
Guest
Posts: n/a
 
      06-30-2004
justme wrote:

> hi
>
> how can i catch Ctrl-x (or any other letters except 'c' ) in perl ??
> thanks..


catch from where? keyboard?

--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
 
Reply With Quote
 
 
 
 
Sherm Pendley
Guest
Posts: n/a
 
      06-30-2004
justme wrote:

> how can i catch Ctrl-x (or any other letters except 'c' ) in perl ??
> thanks..


perldoc -q signal

sherm--

--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Reply With Quote
 
justme
Guest
Posts: n/a
 
      07-01-2004
Abigail <> wrote in message news:<> ...
> justme () wrote on MMMCMLVI September MCMXCIII in
> <URL:news: gle.com>:
> <> hi
> <>
> <> how can i catch Ctrl-x (or any other letters except 'c' ) in perl ??
> <> thanks..
>
>
> What do you mean by "catching" ctrl-x? Matching with a regex?
>
>
> Abigail


hi

i want to catch from the keyboard. I have looked at perldoc -q signal

$Interrupted = 0; # to ensure it has a value
$SIG{INT} = sub {
$Interrupted++;
syswrite(STDERR, "ouch\n", 5);
}

Does this example catch Ctrl-x?
 
Reply With Quote
 
Keith Keller
Guest
Posts: n/a
 
      07-01-2004
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 2004-07-01, justme <> wrote:

> i want to catch from the keyboard. I have looked at perldoc -q signal


perldoc -q signal talks about trapping signals, not catching keystrokes.

> $Interrupted = 0; # to ensure it has a value
> $SIG{INT} = sub {
> $Interrupted++;
> syswrite(STDERR, "ouch\n", 5);
> }
>
> Does this example catch Ctrl-x?


No, it traps SIGINT, which is commonly sent by ctrl-c. IIRC ctrl-x
doesn't normally send a signal, so you can't trap it this way.

Why don't you describe your goal, rather than trying to describe what
you think you want to do? Why are you so concerned with ctrl-x?

- --keith

- --
kkeller-
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFA44FhhVcNCxZ5ID8RAgSfAJwOszJpruEcvk6lD6kgMq SVhWotjwCgjq6C
Ro02Dl1lGYWpTt+NrFDzCAE=
=EM95
-----END PGP SIGNATURE-----
 
Reply With Quote
 
justme
Guest
Posts: n/a
 
      07-02-2004
Keith Keller <kkeller-> wrote in message news:<>...
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 2004-07-01, justme <> wrote:
>
> > i want to catch from the keyboard. I have looked at perldoc -q signal

>
> perldoc -q signal talks about trapping signals, not catching keystrokes.
>
> > $Interrupted = 0; # to ensure it has a value
> > $SIG{INT} = sub {
> > $Interrupted++;
> > syswrite(STDERR, "ouch\n", 5);
> > }
> >
> > Does this example catch Ctrl-x?

>
> No, it traps SIGINT, which is commonly sent by ctrl-c. IIRC ctrl-x
> doesn't normally send a signal, so you can't trap it this way.
>
> Why don't you describe your goal, rather than trying to describe what
> you think you want to do? Why are you so concerned with ctrl-x?
>
> - --keith
>
> - --
> kkeller-
> (try just my userid to email me)
> AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.3 (GNU/Linux)
>
> iD8DBQFA44FhhVcNCxZ5ID8RAgSfAJwOszJpruEcvk6lD6kgMq SVhWotjwCgjq6C
> Ro02Dl1lGYWpTt+NrFDzCAE=
> =EM95
> -----END PGP SIGNATURE-----



actually this is what i want:

A user interface to prompt user to continue or use ctrl-x to return to
previous menu.


eg

"Do you accept? [Yn] or Ctrl-x to return to previous"

When the user press Ctrl-x, it will go back to previous page...

something like that....
thanks
 
Reply With Quote
 
Paul Lalli
Guest
Posts: n/a
 
      07-02-2004
On Fri, 2 Jul 2004, justme wrote:

> actually this is what i want:
>
> A user interface to prompt user to continue or use ctrl-x to return to
> previous menu.
>
>
> eg
>
> "Do you accept? [Yn] or Ctrl-x to return to previous"
>
> When the user press Ctrl-x, it will go back to previous page...


CTRL-X has a ordinal representation of 24. (At least it does for me on
the two systems I tried it out - WinXP and Solaris). Here is a solution
based on the documentation previously suggested to you
perldoc -q single


#!/usr/bin/perl
use strict;
use warnings;
use Term::ReadKey;

print "Do you accept? [Yn] or Ctrl-x to return to previous\n";
ReadMode "raw";
my $key = ReadKey 0, *STDIN;
if (ord($key) == 24) {
previousPage;
} elsif ($key =~ /^y$/i){
heSaidYes;
} else {
heSaidNo;
}


Paul Lalli
 
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
The richtextbox not receiving the keys such Ctrl+A, Ctrl+O when typedon it when hosted on web page Gouri.Mahajan7@gmail.com ASP .Net 0 07-11-2008 05:27 AM
Disabling the shortcuts such as Ctrl+A, Ctrl+B.... using Javascript Gouri.Mahajan7@gmail.com ASP .Net 2 07-10-2008 08:15 AM
How to intercept Ctrl key - eg Ctrl E being pressed on Java console program Angus Java 5 11-18-2006 04:19 PM
Implement Ctrl-C, Ctrl-V Danny C++ 5 08-15-2003 03:04 AM
Implement Ctrl-C, Ctrl-V Danny C Programming 5 08-15-2003 03:04 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57