term_kbgetx
Previous Topic  Next Topic 

Synopsis:

        key=term_kbgetx()


Arguments:

       NONE


Description:   This function suspends the calling task until a key has been hit and returns the four digit scan code of the key that was pressed.   If there are already one or more keys in the keyboard buffer then this function will return immediately with the scan code value of the first key in the keyboard buffer.


The value is NOT removed from the buffer, so repeated calls to term_kbgetx() will continue to give the same value (if there are type-ahead characters, the returned character is always the earliest in the buffer).   A call to term_kbgetx() will generally be followed by a call to term_kbget() to remove the keystroke.


Only one task can be calling term_kbget() or term_kbgetx() at any one time.     If there is already a task waiting for a key press with these functions then any other tasks calling this function will cause the function to display an error message and a blank string ("") will be returned.


It is possible to obtain the number of keys waiting in the keyboard buffer by calling the term_kbqsize() function.


A maximum of 256 keys can be held in the keyboard buffer before they start being overwritten.


The first two characters of the a scan code indicate which key has been pressed.   The second two characters indicate the ASCII code (as a hexadecimal number), if any, for the pressed key.


For example, [Esc] the first key on the keyboard (in the standard IBM layout), and has ASCII code 27 decimal, 1b hexadecimal; hence "011b". Special keys which have no ASCII code have "00" as the last two characters, for example the function key [F1].


The following tables show the scan codes for the special keys:


Function Keys:


key

Scan Code

[F1]

3b00

[F2]

3c00

[F3]

3d00

[F4]

3e00

[F5]

3f00

[F6]

4000

[F7]

4100

[F8]

4200

[F9]

4300

[F10]

4400

[F11],[F12]

ignored


Special Keys:


[Enter]        

1c0d

[]        

4800

[Backspace]        

0e08        

[]        

5000

[Esc]        

011b        

[]        

4d00

[Tab]        

0f09        

[]        

4b00

[Ins]        

5200        

[PgUp]        

4900

[Del]        

5300        

[PgDn]        

5100

[Home]

4700

[End]        

4f00

[Ctrl]+[Enter]                

1c0a        

[Shift]+[Tab]        

0f00


[Alt]+Key:


[A] 1e00

[B] 3000

[C] 2e00

[D] 2000

[E] 1200

[F] 2100

[G] 2200

[H] 2300

[I] 1700

[J] 2400

[K] 2500

[L] 2600

[M] 3200

[N] 3100

[O] 1800

[P] 1900

[Q] 1000

[R] 1300

[S] 1f00

[T] 1400

[U] 1600

[V] 1f00

[W] 1100

[X] 2d00

[Y] 1500

[Z] 2c00

[1] 7800

[2] 7900

[3] 7a00

[4] 7b00

[5] 7c00

[6] 7d00

[7] 7e00

[8] 7f00

[9] 8000

[0] 8100

[-] 0c00

[=] 0d00





The following program prints out the scan codes for each key:


main

var scan:4;

var ch:1;


    while(1)

         scan=kb_getx();

         ch=kb_get();         

         applog("Scab=",scan," ch=",ch);

    endwhile

endmain



Returns:  Returns a string containing the scan code of the key that was pressed.