perl中是否有mouseClicked或keyPressed?

问题描述 投票:1回答:1

我记得当我用Java编写代码时,会有一条命令会感测鼠标单击或按下键。您能以某种方式在perl中做同样的事情吗?像这样的东西

print "\n", "Press the 'I' key for instructions", "\n"; 
my $a = readline STDIN;

chomp $a;

#This next line is what is what I'm thinking of
     if (keyPressed eq "I" || "i")
     {
     print "\n", "Instructions: blah, blah, blah", "\n";
     }
print "\n", "Click your mouse if you want to exit the instructions", "\n";
     while (mouseClicked = True)
     {
     print "\n", "Press the 'I' key for instructions", "\n"; 
          if (keyPressed eq "I" || "i")
          {
          print "\n", "Instructions: blah, blah, blah", "\n";
          }
     print "\n", "Click your mouse if you want to exit the instructions", "\n";
     }     

类似的东西。主要问题:perl中是否有任何mouseClicked或keyPressed(Java)?

perl keypress mouseclick-event
1个回答
0
投票

看看Term::RawInput。这是一些基本示例:

use Term::RawInput;

my $prompt='PROMPT : ';
my ($input,$key)=('','');
($input,$key)=rawInput($prompt,0);

print "\nRawInput=$input" if $input;
print "\nKey=$key\n" if $key;

print "Captured F1\n" if $key eq 'F1';
print "Captured ESCAPE\n" if $key eq 'ESC';
print "Captured DELETE\n" if $key eq 'DELETE';
print "Captured PAGEDOWN\n" if $key eq 'PAGEDOWN';
© www.soinside.com 2019 - 2024. All rights reserved.