Programs
Gkbd Source Code
 previous   up   next 

Gkbd is a keyboard test program for the graphic keyboard.

Gkbd shows keyboard and mouse events. At the top of the window a rectangular block moves forward and backward to show that the program does not hang. An explanation how to terminate the program is also near the top:

Keyboard test program. Type ! to terminate the program

Gkbd logs the keys pressed in the bottom area of the window. The log consists of the decimal key number and an optional key description. E.g.:

8364 €

For Unicode characters the key number corresponds to the ordinal number of the character. Cursor-, function- and mouse-keys correspond to special codes (which may be or may not be Unicode characters). E.g.

1114274 KEY_UP

Key descriptions like KEY_UP correspond to constants defined in the library keybd.s7i. This library defines constants for keys and combinations of a key with one modifier key (SHIFT, CTRL, ALT). Constants from keybd.s7i should be used in programs, because ordinals like 1114274 might change in the future.

The log of keys is also written to stdout. When gkbd was started from a console you can see the log also in the console.

Gkbd displays also an english keyboard with blue keys. This is independent of the actual keyboard type. Keys that are currently pressed are shown in red.

On the top right of the keyboard picture are three lights corresponding to num-lock, shift-lock and scroll-lock.

On the bottom left of the keyboard picture are four lights corresponding to shift, control, super and alt. These lights are red if a left or right modifier key (e.g. shift) is currently pressed.

The mouse keys are at the bottom right of the keyboard area. From left to right there are:

The keyboard/Mouse interface of Seed7 supports reading key/button down events with getc(KEYBOARD). The function getc(KEYBOARD) waits until a key has been pressed. The function inputReady(KEYBOARD) can be used to avoid blocking. This function returns TRUE if reading with getc(KEYBOARD) does not block.

The function getc(KEYBOARD) does not consider key/button release events. The function buttonPressed is used to determine if a key is currently pressed. Note that buttonPressed does not consume events. So a combination of getc(KEYBOARD) and buttonPressed is used by gkbd. Modifier keys such as shift, control, super and alt do not send key/button down or up events. The state of these buttons is also obtained with buttonPressed.

Some keys are not delivered to the program by default. By default the close button of the window (often marked with X) just exits the program. By default resizing a window is also not communicated to the program. These two events can be activated with:

selectInput(curr_win, KEY_CLOSE, TRUE);  # Enable the program to get KEY_CLOSE without closing the window.
selectInput(curr_win, KEY_RESIZE, TRUE); # Enable the program to get KEY_RESIZE.

This way a program can also receive KEY_CLOSE and KEY_RESIZE.


Started

After pressing keys

 previous   up   next