我无法在我的代码中匹配@的密钥代码。我想在keydownhandler中匹配@。我采取了班次+ 2 = @ = 64
itemBox.addKeyDownHandler(new KeyDownHandler() {
@Override
public void onKeyDown(KeyDownEvent event) {
// TODO Auto-generated method stub
if ((int)event.getNativeKeyCode() == 64 )
{
System.out.println("eggheads");
}
}
});
答案 0 :(得分:2)
我得到了所有
inputBox.addKeyPressHandler(new KeyPressHandler() {
public void onKeyPress(KeyPressEvent event) {
// TODO Auto-generated method stub
System.out.println(event.getUnicodeCharCode());
if(event.getUnicodeCharCode() == 64){
item.add(box);
}
}
});
答案 1 :(得分:1)
您可以使用keyPressed
活动
itemBox.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent event) {
if (event.getKeyChar() == '@' )
{}
}
});