Browse Source

+ Added first examples

michael 24 years ago
parent
commit
49de2f8866
1 changed files with 43 additions and 10 deletions
  1. 43 10
      docs/keyboard.tex

+ 43 - 10
docs/keyboard.tex

@@ -111,20 +111,22 @@ var
 
 
 \begin{procedure}{DoneKeyboard}
 \begin{procedure}{DoneKeyboard}
 \Declaration
 \Declaration
-Procedure DoneKeyboard
+Procedure DoneKeyboard;
 \Description
 \Description
 \var{DoneKeyboard} de-initializes the keyboard interface. 
 \var{DoneKeyboard} de-initializes the keyboard interface. 
 It clears up any allocated memory, or restores the console or terminal 
 It clears up any allocated memory, or restores the console or terminal 
 the program was running in to its initial state. This function should 
 the program was running in to its initial state. This function should 
-be called on program exit. Failing to do so may leave the terminal in 
-unusable state. Its exact action depends on the platform on which the 
-program is running.
+be called on program exit. Failing to do so may leave the terminal or
+console window in an unusable state. Its exact action depends on the 
+platform on which the program is running.
 \Errors
 \Errors
 None.
 None.
 \SeeAlso
 \SeeAlso
 \seep{InitKeyBoard}
 \seep{InitKeyBoard}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see most other functions.
+
 \begin{function}{GetKeyEvent}
 \begin{function}{GetKeyEvent}
 \Declaration
 \Declaration
 function GetKeyEvent: TKeyEvent;
 function GetKeyEvent: TKeyEvent;
@@ -133,20 +135,31 @@ function GetKeyEvent: TKeyEvent;
 \var{PendingKeyEvent}, or waits for one if none is available.
 \var{PendingKeyEvent}, or waits for one if none is available.
 A non-blocking version is available in \seef{PollKeyEvent}.
 A non-blocking version is available in \seef{PollKeyEvent}.
 
 
-The returned key is encoded as a \var{TKeyEvent} type variable. 
-See the types section for a description of how the key is described.
+The returned key is encoded as a \var{TKeyEvent} type variable, and
+is normally the physical key code, which can be translated with one
+of the translation functions \seef{TranslateKeyEvent} or
+\seef{TranslateKeyEventUniCode}. See the types section for a 
+description of how the key is described.
 \Errors
 \Errors
 If no key became available, 0 is returned.
 If no key became available, 0 is returned.
 \SeeAlso
 \SeeAlso
-\seep{PutKeyEvent}, \seef{PollKeyEvent}
+\seep{PutKeyEvent}, \seef{PollKeyEvent}, \ßeef{TranslateKeyEvent},
+\seef{TranslateKeyEventUniCode}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex1}
+
 \begin{function}{GetKeyEventChar}
 \begin{function}{GetKeyEventChar}
 \Declaration
 \Declaration
 function GetKeyEventChar(KeyEvent: TKeyEvent): Char;
 function GetKeyEventChar(KeyEvent: TKeyEvent): Char;
 \Description
 \Description
 \var{GetKeyEventChar} returns the charcode part of the given 
 \var{GetKeyEventChar} returns the charcode part of the given 
-\var{KeyEvent}, if it contains a translated keycode.
+\var{KeyEvent}, if it contains a translated character key 
+keycode. The charcode is simply the ascii code of the 
+character key that was pressed.
+
+It returns the null character if the key was not a character key, but e.g. a
+function key.
 \Errors
 \Errors
 None.
 None.
 \SeeAlso
 \SeeAlso
@@ -157,12 +170,16 @@ None.
 \seef{GetKeyEvent}
 \seef{GetKeyEvent}
 \end{function}
 \end{function}
 
 
+For an example, see \seef{GetKeyEvent}
+
 \begin{function}{GetKeyEventCode}
 \begin{function}{GetKeyEventCode}
 \Declaration
 \Declaration
 function GetKeyEventCode(KeyEvent: TKeyEvent): Word;
 function GetKeyEventCode(KeyEvent: TKeyEvent): Word;
 \Description
 \Description
 \var{GetKeyEventCode} returns the translated function keycode part of 
 \var{GetKeyEventCode} returns the translated function keycode part of 
-the given KeyEvent, if it contains a translated function keycode.
+the given KeyEvent, if it contains a translated function key.
+
+If the key pressed was not a function key, the null character is returned.
 \Errors
 \Errors
 None.
 None.
 \SeeAlso
 \SeeAlso
@@ -173,6 +190,8 @@ None.
 \seef{GetKeyEvent}
 \seef{GetKeyEvent}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex2}
+
 \begin{function}{GetKeyEventFlags}
 \begin{function}{GetKeyEventFlags}
 \Declaration
 \Declaration
 function GetKeyEventFlags(KeyEvent: TKeyEvent): Byte;
 function GetKeyEventFlags(KeyEvent: TKeyEvent): Byte;
@@ -189,13 +208,21 @@ None.
 \seef{GetKeyEvent}
 \seef{GetKeyEvent}
 \end{function}
 \end{function}
 
 
+For an example, see \seef{GetKeyEvent}
+
 \begin{function}{GetKeyEventShiftState}
 \begin{function}{GetKeyEventShiftState}
 \Declaration
 \Declaration
 function GetKeyEventShiftState(KeyEvent: TKeyEvent): Byte;
 function GetKeyEventShiftState(KeyEvent: TKeyEvent): Byte;
 \Description
 \Description
 \var{GetKeyEventShiftState} returns the shift-state values of 
 \var{GetKeyEventShiftState} returns the shift-state values of 
-the given \var{KeyEvent}.
+the given \var{KeyEvent}. This can be used to detect which of the modifier
+keys \var{Shift}, \var{Alt} or \var{Ctrl} were pressed. If none were
+pressed, zero is returned.
+
+Note that this function does not always return expected results;
+In a unix X-Term, the modifier keys do not always work.
 \Errors
 \Errors
+None.
 \SeeAlso
 \SeeAlso
 \seef{GetKeyEventUniCode},
 \seef{GetKeyEventUniCode},
 \seef{GetKeyEventFlags}, 
 \seef{GetKeyEventFlags}, 
@@ -204,6 +231,8 @@ the given \var{KeyEvent}.
 \seef{GetKeyEvent}
 \seef{GetKeyEvent}
 \end{function}
 \end{function}
 
 
+\FPCexample{ex3}
+
 \begin{function}{GetKeyEventUniCode}
 \begin{function}{GetKeyEventUniCode}
 \Declaration
 \Declaration
 function GetKeyEventUniCode(KeyEvent: TKeyEvent): Word;
 function GetKeyEventUniCode(KeyEvent: TKeyEvent): Word;
@@ -221,6 +250,8 @@ None.
 \seef{GetKeyEvent}
 \seef{GetKeyEvent}
 \end{function}
 \end{function}
 
 
+No example yet.
+
 \begin{procedure}{InitKeyBoard}
 \begin{procedure}{InitKeyBoard}
 \Declaration
 \Declaration
 procedure InitKeyboard;
 procedure InitKeyboard;
@@ -237,6 +268,8 @@ None.
 \seep{DoneKeyBoard}
 \seep{DoneKeyBoard}
 \end{procedure}
 \end{procedure}
 
 
+For an example, see most other functions.
+
 \begin{function}{IsFunctionKey}
 \begin{function}{IsFunctionKey}
 \Declaration
 \Declaration
 function IsFunctionKey(KeyEvent: TKeyEvent): Boolean;
 function IsFunctionKey(KeyEvent: TKeyEvent): Boolean;