如何在KeyboardKey上捕获onKeyLongPress。下面的代码只有在我输入“KEYCODE_VOLUME_DOWN”或“KEYCODE_VOLUME_UP”而不是“KEYCODE_Q”时才有效。如果您需要XML,请询问。我试着写“113”而不是“KeyEvent.KEYCODE_Q”,但我没有帮忙。
value = {'time':['9599','MS'],'What is your birth place?':['USA']}
import json
value = (json.dumps(value),)
print value
>> ('{"What is your birth place?": ["USA"], "time": ["9599", "MS"]}', )
答案 0 :(得分:0)
我长按空格键的解决方案。
private long ms_press;
...
@Override
public void onPress( int i ){
ms_press = System.currentTimeMillis();
}
...
@Override
public void onKey( int primaryCode, int[] keyCodes) {
if( primaryCode == 32 && (System.currentTimeMillis()-ms_press) >= 1000 ){
//long press on Space key
}else{
//...
}
}