作者qrtt1 (隐者)
看板java
标题Re: [问题] keyEvent 疑问
时间Tue Apr 11 22:25:58 2006
※ 引述《forever60713 (横渡交大沙漠中...)》之铭言:
: 我想要做计算机程式
: 不仅仅可以透过按下按钮来输入,也希望可以透过键盘输入来输入
: 我就想说用 keyEvent
: 大概只写了这样,但是却不行耶
: 我要的是getKeyChar() 得到的char 跟 键盘上面 1 一样
: 我就在textArea 那边,append 1
: 那我应该要怎麽写比较好呢~麻烦罗^_^
: -------------------------------------------------------
: static class keyLis extends KeyAdapter
: {
: public void keyPressed (KeyEvent keyE)
: {
: if ('1'==keyE.getKeyChar()) txa.append("1");
: }
: }//keyLis
也许改用
public int getKeyCode()
侦测2组答案
public static final int VK_0 48
public static final int VK_1 49
public static final int VK_2 50
public static final int VK_3 51
public static final int VK_4 52
public static final int VK_5 53
public static final int VK_6 54
public static final int VK_7 55
public static final int VK_8 56
public static final int VK_9 57
public static final int VK_NUMPAD0 96
public static final int VK_NUMPAD1 97
public static final int VK_NUMPAD2 98
public static final int VK_NUMPAD3 99
public static final int VK_NUMPAD4 100
public static final int VK_NUMPAD5 101
public static final int VK_NUMPAD6 102
public static final int VK_NUMPAD7 103
public static final int VK_NUMPAD8 104
public static final int VK_NUMPAD9 105
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 163.26.34.20