moka.io
Class Keyboard

java.lang.Object
  extended bymoka.lang.Object
      extended bymoka.io.Keyboard

public class Keyboard
extends Object

Class Keyboard is used to get low-level input from the keyboard. Note that some methods has a static version. These methods are written with an uppercase letter in this document to differenciate them from their instance counterparts, but they must be write with a lowercase in a program. Ex: Keyboard.ngetchx() (Althrought it is written Ngetchx in this doccument)

Since:
MDK1.0a

Field Summary
static short ALPHA_KEY_COUNT
          The number of alphabetic key the keyboard class handle.
 byte key_2nd
           
 byte key_A
           
 byte key_APPS
           
static short KEY_APPS
          The APPS key.
 byte key_B
           
static short KEY_BACKSPACE
          The BACKSPACE key.
 byte key_C
           
static short KEY_CHAR
          The CHAR key.
static short KEY_CLEAR
          The CLEAR key.
static short KEY_COUNT
          The number of key the keyboard class handle.
 byte key_D
           
 byte key_Diamnd
           
 byte key_Down
           
 byte key_E
           
 byte key_ENTER
           
static short KEY_ENTER
          The ENTER key.
 byte key_ENTER1
           
 byte key_ENTER2
           
static short KEY_ENTRY
          The ENTRY key.
 byte key_ESC
           
static short KEY_ESC
          The ESC key.
 byte key_F
           
 byte key_F1
           
static short KEY_F1
          The F1 key.
 byte key_F2
           
static short KEY_F2
          The F2 key.
 byte key_F3
           
static short KEY_F3
          The F3 key.
 byte key_F4
           
static short KEY_F4
          The F4 key.
 byte key_F5
           
static short KEY_F5
          The F5 key.
static short KEY_F6
          The F6 key.
static short KEY_F7
          The F7 key.
static short KEY_F8
          The F8 key.
 byte key_G
           
 byte key_H
           
 byte key_I
           
static short KEY_INS
          The INS key.
 byte key_J
           
 byte key_K
           
 byte key_L
           
 byte key_Left
           
 byte key_M
           
static short KEY_MATH
          The MATH key.
static short KEY_MEM
          The MEM key.
static short KEY_MODE
          The MODE key.
 byte key_N
           
 byte key_O
           
static short KEY_OFF
          The OFF key.
static short KEY_ON
          The ON key.
 byte key_P
           
 byte key_Q
           
static short KEY_QUIT
          The QUIT key.
 byte key_R
           
static short KEY_RCL
          The RCL key.
 byte key_Right
           
 byte key_S
           
 byte key_Shift
           
static short KEY_SIGN
          The SIGN key.
static short KEY_STO
          The STO key.
static short KEY_SWITCH
          The SWITCH key.
 byte key_T
           
 byte key_U
           
 byte key_Up
           
 byte key_V
           
static short KEY_VARLNK
          The VARLNK key.
 byte key_W
           
 byte key_X
           
 byte key_Y
           
 byte key_Z
           
static short SYSTEM_KEY_COUNT
          The number of system key the keyboard class handle.
 
Constructor Summary
Keyboard()
          Initializes a newly allocated Keyboard.
 
Method Summary
 void checkKeys()
          Checks if any key of the keyboard is pressed.
 void checkSysKeys()
          Checks if any "system" key is pressed.
static void flush()
          Flushes the keyboard queue.
 short getKey()
          Returns the key actually pressed.
static short GetKey()
          Checks to see if a keystroke is currently available.
static short getKey(int delay)
          Returns the key pressed in a specified delay.
 boolean hit()
          Checks if a key is pressed.
static boolean kbhit()
          Checks if a key stroke is available.
 short ngetchx()
          Wait for the user to press a key, then return the key.
static short Ngetchx()
          Wait for the user to press a key, then return the key.
static short ngetchx(int delay)
          Wait a specified delay for the user to press a key, then return the key.
 char readAlpha()
          Returns the first (in alphabetic order) of the alphabetic keys pressed.
 
Methods inherited from class moka.lang.Object
equals, finalize, getClassName, toString
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

KEY_COUNT

public static final short KEY_COUNT
The number of key the keyboard class handle.

See Also:
Constant Field Values

SYSTEM_KEY_COUNT

public static final short SYSTEM_KEY_COUNT
The number of system key the keyboard class handle.

See Also:
Constant Field Values

ALPHA_KEY_COUNT

public static final short ALPHA_KEY_COUNT
The number of alphabetic key the keyboard class handle.

See Also:
Constant Field Values

KEY_F1

public static final short KEY_F1
The F1 key.

See Also:
Constant Field Values

KEY_F2

public static final short KEY_F2
The F2 key.

See Also:
Constant Field Values

KEY_F3

public static final short KEY_F3
The F3 key.

See Also:
Constant Field Values

KEY_F4

public static final short KEY_F4
The F4 key.

See Also:
Constant Field Values

KEY_F5

public static final short KEY_F5
The F5 key.

See Also:
Constant Field Values

KEY_F6

public static final short KEY_F6
The F6 key.

See Also:
Constant Field Values

KEY_F7

public static final short KEY_F7
The F7 key.

See Also:
Constant Field Values

KEY_F8

public static final short KEY_F8
The F8 key.

See Also:
Constant Field Values

KEY_ESC

public static final short KEY_ESC
The ESC key.

See Also:
Constant Field Values

KEY_QUIT

public static final short KEY_QUIT
The QUIT key.

See Also:
Constant Field Values

KEY_APPS

public static final short KEY_APPS
The APPS key.

See Also:
Constant Field Values

KEY_SWITCH

public static final short KEY_SWITCH
The SWITCH key.

See Also:
Constant Field Values

KEY_MODE

public static final short KEY_MODE
The MODE key.

See Also:
Constant Field Values

KEY_BACKSPACE

public static final short KEY_BACKSPACE
The BACKSPACE key.

See Also:
Constant Field Values

KEY_INS

public static final short KEY_INS
The INS key.

See Also:
Constant Field Values

KEY_CLEAR

public static final short KEY_CLEAR
The CLEAR key.

See Also:
Constant Field Values

KEY_VARLNK

public static final short KEY_VARLNK
The VARLNK key.

See Also:
Constant Field Values

KEY_CHAR

public static final short KEY_CHAR
The CHAR key.

See Also:
Constant Field Values

KEY_ENTER

public static final short KEY_ENTER
The ENTER key.

See Also:
Constant Field Values

KEY_ENTRY

public static final short KEY_ENTRY
The ENTRY key.

See Also:
Constant Field Values

KEY_STO

public static final short KEY_STO
The STO key.

See Also:
Constant Field Values

KEY_RCL

public static final short KEY_RCL
The RCL key.

See Also:
Constant Field Values

KEY_SIGN

public static final short KEY_SIGN
The SIGN key.

See Also:
Constant Field Values

KEY_MATH

public static final short KEY_MATH
The MATH key.

See Also:
Constant Field Values

KEY_MEM

public static final short KEY_MEM
The MEM key.

See Also:
Constant Field Values

KEY_ON

public static final short KEY_ON
The ON key.

See Also:
Constant Field Values

KEY_OFF

public static final short KEY_OFF
The OFF key.

See Also:
Constant Field Values

key_Diamnd

public byte key_Diamnd

key_Shift

public byte key_Shift

key_2nd

public byte key_2nd

key_APPS

public byte key_APPS

key_ESC

public byte key_ESC

key_Right

public byte key_Right

key_Down

public byte key_Down

key_Left

public byte key_Left

key_Up

public byte key_Up

key_ENTER

public byte key_ENTER

key_ENTER1

public byte key_ENTER1

key_ENTER2

public byte key_ENTER2

key_F1

public byte key_F1

key_F2

public byte key_F2

key_F3

public byte key_F3

key_F4

public byte key_F4

key_F5

public byte key_F5

key_A

public byte key_A

key_B

public byte key_B

key_C

public byte key_C

key_D

public byte key_D

key_E

public byte key_E

key_F

public byte key_F

key_G

public byte key_G

key_H

public byte key_H

key_I

public byte key_I

key_J

public byte key_J

key_K

public byte key_K

key_L

public byte key_L

key_M

public byte key_M

key_N

public byte key_N

key_O

public byte key_O

key_P

public byte key_P

key_Q

public byte key_Q

key_R

public byte key_R

key_S

public byte key_S

key_T

public byte key_T

key_U

public byte key_U

key_V

public byte key_V

key_W

public byte key_W

key_X

public byte key_X

key_Y

public byte key_Y

key_Z

public byte key_Z
Constructor Detail

Keyboard

public Keyboard()
Initializes a newly allocated Keyboard.

Method Detail

checkSysKeys

public void checkSysKeys()
Checks if any "system" key is pressed.


ngetchx

public short ngetchx()
Wait for the user to press a key, then return the key.

Returns:
the key pressed

Ngetchx

public static short Ngetchx()
Wait for the user to press a key, then return the key.

Returns:
the key pressed

ngetchx

public static short ngetchx(int delay)
Wait a specified delay for the user to press a key, then return the key.

Parameters:
delay - The delay
Returns:
the key actually pressed or null if no key is pressed.

GetKey

public static short GetKey()
Checks to see if a keystroke is currently available. If so returns a nonzero integer (in fact, it returns the exactly same value as ngetchx); if not, it returns 0.

Returns:
a nonzero integer or 0 if no keystroke is currently available.

checkKeys

public void checkKeys()
Checks if any key of the keyboard is pressed.


readAlpha

public char readAlpha()
Returns the first (in alphabetic order) of the alphabetic keys pressed. If no such key is pressed, the null character is returned.

Returns:
the first alphabetic key pressed or the null character if no such key is pressed.

hit

public boolean hit()
Checks if a key is pressed.

Returns:
true if any key is pressed, false otherwize.

kbhit

public static boolean kbhit()
Checks if a key stroke is available.

Returns:
true if a key stroke is available, false otherwize.

flush

public static void flush()
Flushes the keyboard queue.


getKey

public static short getKey(int delay)
Returns the key pressed in a specified delay. If two keys are pressed, the last key pressed is returned. If no key is pressed during the specified delay, the null character ('\0') is returned.

Parameters:
delay - The delay
Returns:
the key actually pressed or null if no key is pressed.

getKey

public short getKey()
Returns the key actually pressed. If two keys are pressed, the one with the lesser value is returned. If no key is pressed, the null character is returned.

Returns:
the key actually pressed or null if no key is pressed.