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

Re: [MacPerl] Keyboard question



At 11.13 +0200 2000.03.23, miku wrote:
>Hi all,
>
>is there a way to determine from inside MacPerl which key the user is
>currently pressing? It would be great if there is a way of getting also the
>status of the modifier keys like Shift (left/right), Control, Alternate,
>Command. And, most important: to get this information without halting the
>program run, on the fly.

>X-Authentication-Warning: cfcl.com: majordom set sender to
>owner-macperl@macperl.org using -f
>X-Sent-To: <macperl@macperl.org>
>X-Sender: gs53618@mail.navix.net
>Date: Thu, 17 Jun 1999 16:49:35 -0500
>To: Darryl Tang <darryl@yoshisonline.com>
>From: Greenblatt & Seay <g-s@navix.net>
>Subject: [MacPerl] Re: mouse detection
>Cc: macperl@macperl.org
>Sender: owner-macperl@macperl.org
>Status:
>
>#!perl
>
># Keyboard Keys and Mouse Detection
># Collected and adapted by David Seay
>
>use Mac::Events;
>use Mac::Events qw(@Event $CurrentEvent);
>use Mac::LowMem;
>use Mac::QuickDraw;
>
>$Event[keyDown]   = \&keyDown_Handler;
>$Event[mouseDown] = \&mouseDown_Handler;
>
>print "Hold down the shift, control, option, and/or command keys and click
>the mouse or press a key on the keyboard.
>  Type command period to quit.\n\n";
>
>
>  WaitNextEvent while !$flag;
>
>sub keyDown_Handler {
>	my($ev) = @_;
>	$k = chr($ev->character);
>	$modKey = ($CurrentEvent->modifiers);
>	print "KEY DOWN = $k\nMODIFIER KEY = $modKey\n\n";
>	if ($modKey == 256 && $k eq ".") { $flag = 1 } # COMMAND '.' QUITS
>THE PROGRAM
>}
>
>sub mouseDown_Handler {
>	$modKey = ($CurrentEvent->modifiers);
>	$clk = LMGetMouseLocation();
>	($horz, $vert) = ($clk->h, $clk->v);
>	print "MOUSE CLICKED at H = $horz   V = $vert\nMODIFIER KEY =
>$modKey\n\n";
>}
>
>
>
>===== Want to unsubscribe from this list?
>===== Send mail with body "unsubscribe" to macperl-request@macperl.org
>

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org