How to disable all keys except <Enter>?


I need to disable in my program all keyboard events excluding <Enter> key. I need to disable the GNOME keyboard shortcuts etc. It should look like gksu application. Is there any way to do this? I'm trying this code (stolen from gtk2-perl study guide):

$window->signal_connect( 'key-press-event' => \&disable_keys);
sub disable_keys
 my ($widget,$event,$parameter)= @_;
 my $key_nr = $event->keyval();

 foreach my $key  (keys %Gtk2::Gdk::Keysyms){
   my $key_compare = $Gtk2::Gdk::Keysyms{$key};

   if($key_compare == $key_nr){
     print ("You typed $key \n");
     if($key_nr == 65293) {
       # Do something more ...
     } else {
       # Do nothing
 return FALSE;

But without success. It looks like the &disable_keys function isn't called by 'key-press-event'. What I am doing wrong?



Lumír Jasiok
VSB-TU Ostrava - Computer centre
E-mail: lumir jasiok vsb cz

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]