Subject: | "Modifier" key releases don't track key presses correctly |
Using Ali Corbin's quick-and-dirty program to print out key presses *and
releases* (below) shows the following:
Pressing Control_R results in:
Control_R pressed
Control_L released <--- should be Control_R
Pressing Control_L results in:
Control_L pressed
Control_L released <--- correct
The same problem happens with Alt and Shift; ie - the "press" of Alt_R
is correct, but the *release* reports Alt_L.
This makes it fairly difficult for a program to keep track of key modifiers.
Using strawberry perl on WinXP with Service pack 2. Tk version 804.028
01fvhx
#################################################################
#
# (Program modified to include key release as well as press)
#
#!/usr/local/bin/perl -w
use Tk;
$top = MainWindow->new();
$frame = $top->Frame( -height => '6c', -width => '6c',
-background => 'black', -cursor => 'gobbler' );
$frame->pack;
$top->bind( '<Any-KeyPress>' => sub
{
my($c) = @_;
my $e = $c->XEvent;
my( $x, $y, $W, $K, $A ) = ( $e->x, $e->y, $e->K, $e->W, $e->A );
print "A key was pressed:\n";
print " x = $x\n";
print " y = $y\n";
print " W = $K\n";
print " K = $W\n";
print " A = $A\n";
} );
$top->bind( '<Any-KeyRelease>' => sub
{
my($c) = @_;
my $e = $c->XEvent;
my( $x, $y, $W, $K, $A ) = ( $e->x, $e->y, $e->K, $e->W, $e->A );
print "A key was released:\n";
print " x = $x\n";
print " y = $y\n";
print " W = $K\n";
print " K = $W\n";
print " A = $A\n";
} );
MainLoop();
Subject: | Test.pl |
#!/usr/local/bin/perl -w
use Tk;
$top = MainWindow->new();
$frame = $top->Frame( -height => '6c', -width => '6c',
-background => 'black', -cursor => 'gobbler' );
$frame->pack;
$top->bind( '<Any-KeyPress>' => sub
{
my($c) = @_;
my $e = $c->XEvent;
my( $x, $y, $W, $K, $A ) = ( $e->x, $e->y, $e->K, $e->W, $e->A );
print "A key was pressed:\n";
print " x = $x\n";
print " y = $y\n";
print " W = $K\n";
print " K = $W\n";
print " A = $A\n";
} );
$top->bind( '<Any-KeyRelease>' => sub
{
my($c) = @_;
my $e = $c->XEvent;
my( $x, $y, $W, $K, $A ) = ( $e->x, $e->y, $e->K, $e->W, $e->A );
print "A key was released:\n";
print " x = $x\n";
print " y = $y\n";
print " W = $K\n";
print " K = $W\n";
print " A = $A\n";
} );
MainLoop();