[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] modifier key detection



In the following script I can detect when the option key is down while a
key is pressed but I can't detect when the option key is down while the
mouse is clicked.

Can the modifier keys be detected without another key being pressed on the
keyboard?

Thanks.

David Seay
http://www.mastercall.com/g-s

-------------------

#!perl

use Mac::Events;
use Mac::Events qw(@Event $CurrentEvent);
use Mac::LowMem;

$Event[keyDown]   = \&keyDown_Handler;
$Event[mouseDown] = \&mouseDown_Handler;

WaitNextEvent while !$flag;

sub keyDown_Handler {
  my($ev) = @_;
  $k = chr($ev->character);
  if (($CurrentEvent->modifiers & 256) == 256 && $k eq ".") { $flag = 1 } #
COMMAND "."
  else { print "KEY DOWN = $k\n" }
  if (($CurrentEvent->modifiers & 2176) == 2176) { print "\b (OptionKey)\n" }
}

sub mouseDown_Handler {
  print "MOUSE DOWN\n";
  if (($CurrentEvent->modifiers & 2176) == 2176) { print "\b (OptionKey)\n" }
}



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch