in reply to Binding AltGr + minus key (=asterisk)
#!/usr/bin/perl use warnings; use strict; use Tk qw{ MainLoop Ev }; my $mw = 'MainWindow'->new; $mw->Label(-text => 'Press any key')->pack; $mw->Entry(-textvariable => \ my $text, -state => 'readonly')->pack; $mw->bind('<KeyPress>', [sub { $text = $_[1] }, Ev('K')]); my @mods = ("", qw( Alt Shift Control Mod4 )); for my $p1 (0 .. $#mods) { for my $p2 (0 .. $#mods) { next if $p2 == 0 && $p1 != 0 || $p2 && $p1 >= $p2; for my $p3 (1 .. $#mods) { next if $p3 <= $p2; my $prefix = join '-', grep length, @mods[$p1, $p2, $p3]; $mw->bind("<$prefix-KeyPress>", [sub { $text = "$_[1] + $_ +[2]" }, "$prefix", Ev('K')]); } } } $mw->bind("<Alt-Shift-Control-Mod4-KeyPress>", [sub { $text = "$_[1] + $_[2]" }, 'Alt-Shift-Control-Meta', Ev('K')]); MainLoop();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Binding AltGr + minus key (=asterisk)
by Anonymous Monk on May 01, 2024 at 23:00 UTC |