Keyboard Events

FL_KEYBOARD

A key press. The key pressed can be found in Fl::event_key(). The text that the key should insert can be found with Fl::event_text() and its length is in Fl::event_length(). If you use the key handle() should return 1. If you return zero then FLTK assummes you ignored the key. It will then attempt to send it to a parent widget. If none of them want it, it will change the event into a FL_SHORTCUT event.

To receive FL_KEYBOARD events you must also respond to the FL_FOCUS and FL_UNFOCUS events.

FL_SHORTCUT

If the Fl::focus() widget is zero or ignores an FL_KEYBOARD event then FLTK tries sending this event to every widget it can, until one of them returns non-zero. FL_SHORTCUT is first sent to the belowmouse() widget, then its parents and siblings, and eventually to every widget in the window, trying to find an object that returns non-zero. FLTK tries really hard to not to ignore any keystrokes!

You can also make "global" shortcuts by using Fl::add_handler(). A global shortcut will work no matter what windows are displayed or which one has the focus.