Class Key

Class Key

Placement in the overall structure

Module
machine
Base classes
None
Derived classes
None
Time of creation
Specification of Task 1
Files
key.h

Description

This class represents the codes of a key as provided by the Keyboard_Controllers methods. It includes methods for setting and, most importantly, conveniently getting these codes.

The essential information that the keyboard provides for each keystroke is the ASCII code, the scan code and the indication which of the modifier keys (Shift, Ctrl, Alt, CapsLock, NumLock, ScrollLock) were active at that time.

Public constants

del
Scancode of key del (or entf).
up
Scancode of key cursor up
down
Scancode of key cursor down
left
Scancode of key cursor left
right
Scancode of key cursor right

Public methods

unsigned char ascii()
returns the ASCII code of the key
unsigned char scancode
returns the scancode of the key
bool ctrl ()
returns true if one of the ctrl (or strg) keys was pressed.
bool alt ()
returns true if one of the alt keys was pressed.
bool valid ()
indicates whether the key description is valid. For this purpose, it is simply checked whether the scancode is not equal to zero. A correct match of ASCII and scancode, however, is not checked.

Further public methods can be taken from the class definition.