package com.sliw.graphics; import javax.microedition.lcdui.Canvas; import javax.microedition.lcdui.Graphics; public class KeyEventCanvas extends Canvas{ public static final int KEY_UP = -1; public static final int KEY_DOWN = -2; public static final int KEY_LEFT = -3; public static final int KEY_RIGHT = -4; public static final int mkey0 = 48; public static final int mkey1 = 49; public static final int mkey2 = 50; public static final int mkey3 = 51; public static final int mkey4 = 52; public static final int mkey5 = 53; public static final int mkey6 = 54; public static final int mkey7 = 55; public static final int mkey8 = 56; public static final int mkey9 = 57; protected void paint(Graphics arg0) { // TODO Auto-generated method stub } /** * 键按下时的操作 */ protected void keyPressed(int keyCode) { // TODO Auto-generated method stub System.out.println("keyCode=" + keyCode); super.keyPressed(keyCode); } /** * 按键释放时的操作 */ protected void keyReleased(int keyCode) { // TODO Auto-generated method stub super.keyReleased(keyCode); } }