|
@@ -125,22 +125,37 @@ export default defineComponent({
|
|
|
chooseQuestion(store.currentTask.questionList[idx + 1]);
|
|
|
}
|
|
|
}
|
|
|
+ // 处理回退删除分数
|
|
|
+ if (event.key === "Backspace") {
|
|
|
+ if (keys.length > 0) {
|
|
|
+ keys.splice(keys.length - 1, 1);
|
|
|
+ } else {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (event.key === "Escape") {
|
|
|
+ keys = [];
|
|
|
+ }
|
|
|
+
|
|
|
// TODO: 确认数字按键的间隔
|
|
|
if (event.timeStamp - keyPressTimestamp > 1.5 * 1000) {
|
|
|
keys = [];
|
|
|
}
|
|
|
keyPressTimestamp = event.timeStamp;
|
|
|
- keys.push(event.key);
|
|
|
- if (isNaN(parseFloat(keys.join("")))) {
|
|
|
- keys = [];
|
|
|
+ // 此时不再接受任何非数字键
|
|
|
+ if (".0123456789".includes(event.key)) {
|
|
|
+ keys.push(event.key);
|
|
|
}
|
|
|
- if (event.key === "Escape") {
|
|
|
+ if (isNaN(parseFloat(keys.join("")))) {
|
|
|
keys = [];
|
|
|
}
|
|
|
const score = parseFloat(keys.join(""));
|
|
|
if (isNumber(score) && questionScoreSteps.value.includes(score)) {
|
|
|
store.currentQuestion.score = score;
|
|
|
}
|
|
|
+ if (keys.length === 0) {
|
|
|
+ store.currentQuestion.score = null;
|
|
|
+ }
|
|
|
}
|
|
|
onMounted(() => {
|
|
|
document.addEventListener("keydown", numberKeyListener);
|