PHP-GTK
Saturday, August 23, 2014 
download | documentation | applications | faq | changelog | resources 


search for in the  


previoushierarchy-changed
key-release-eventnext

Last updated: Sun, 12 May 2013
view this page in English

key-press-event

This signal is emitted when a key has been pressed down.

Useful event properties are:

Example 155. Using the key-press-event signal

<?php
$wnd = new GtkWindow();
$wnd->connect_simple('destroy', array('Gtk', 'main_quit'));
 
//we want to receive key press events
$wnd->connect('key-press-event', 'onKeyPress');
 
//here we handle the key press events
function onKeyPress($widget, $event) {
    if ($event->state & Gdk::CONTROL_MASK && $event->keyval == Gdk::KEY_q) {
        //Press Ctrl+q, and the window will be closed
        $widget->destroy();
    } else if ($event->keyval == Gdk::KEY_F1) {
        //Press F1 to shwo a help text in the title
        $widget->set_title('Press Ctrl+Q to quit');
    }
}
 
$wnd->show();
Gtk::main();
?>

Callback function


User Contributed Notes
gtk.gtkwidget.signal.key-press-event.php
add a note about notes
There are no user contributed notes for this page.


previoushierarchy-changed
key-release-eventnext

Last updated: Sun, 12 May 2013
view this page in English


credits 

PHP  Copyright © 2001-2014 The PHP Group
 All rights reserved.
Last updated: Sun May 12 20:51:01 2013 CEST