使用 GameCanvas 获取 J2ME 中的按键
我想知道(例如)是否按下了 3 键 (KEY_NUM3
)。
我已尝试 getKeyStates
但它仅检测游戏操作键。
如何获取非游戏操作键的状态?
(我已经重写了 Canvas 的 keyPressed
和 keyReleased
函数,并将按键状态存储在数组中(我使用 Vector
来存储,但是我认为也可以将它们存储在数组中,如果这是问题的话),但这似乎不是很好)
I would like to get whether (for example) the 3 key is pressed (KEY_NUM3
).
I have tried getKeyStates
but it only detects the game action keys.
How could I get the states of non-game action keys?
(I have overridden the keyPressed
and keyReleased
functions of Canvas and storing the key states in an array (I'm using a Vector
for storing but I think could store them in an array too, if that's the problem), but this does not seem to be very nice)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的按键中使用像这样传入的
keyCode
in your keypressed use the
keyCode
passed in like so我想这可以是
类似于下面的代码
,但可以
I suppose that can be
something like the code below
but can be