in reply to Tk bind key hexadecimal value

Hello dunno if I understood, but you probably find XEvent useful. See it here explained

use strict; use Tk; my $mw = MainWindow->new; $mw->bind('<KeyPress>' => \&print_keysym); $mw->Button( -text => 'Exit', -command => sub { exit(); } )->pack; MainLoop; sub print_keysym { my $widget = shift; my $e = $widget->XEvent; my ($keysym_text, $keysym_decimal) = ($e->K, $e->N); print "keysym=$keysym_text, numberic=$keysym_decimal\n"; }

See it Keyboard input with Perl/Tk's -bind()

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Replies are listed 'Best First'.
Re^2: Tk bind key hexadecimal value
by Anonymous Monk on Apr 20, 2018 at 16:21 UTC

    Thank you. But this is not exactly what I want, because both $e->K and $e->N depend on the keyboard language. If I change my keyboard language /both on macOS and on Win32, for the same "physical" key I get different values. In this way I need to know beforehand the language of the keyboard to perform my new keyboard mapping. I was hoping that each key of the keyboard has a unique identifier which is bound with the hardware (also with the physical keys) and not change depending on the keyboard input language.

      Maybe I do not need to go so deep as I thought and get the key "hardware code", I could just "translate" any value of a keyboard press ($e->K) to another value