This Java tips describes the method of handling keyEvents on mobile device. This tip may help game developers in developing 'key' features of their applications.

 public void paint(Graphics g) {
    
    g.drawString(msg,0,25,g.TOP|g.LEFT);
    g.drawString("press any KEY",0,80,g.TOP|g.LEFT);
    
}

//Handling keyEvents
protected void keyPressed(int keyCode) {
    
    msg= "keyCode:" + keyCode;
    
    switch(keyCode)  {
        case '1':
            msg+=" hello"
                    break;
        case '2':
            msg+=" from"
                    break;
        case '3':
            msg+=" jjkk"
                    break;
    }
    repaint();
}