加入键盘awsd交互

This commit is contained in:
shefengchun 2023-03-03 14:09:59 +08:00
parent 70cb05c4ce
commit c62a34e34b
3 changed files with 86 additions and 0 deletions

View File

@ -583,6 +583,7 @@ export default defineComponent({
set_cache.value = JSON.parse(sessionStorage.DensityCorrection); set_cache.value = JSON.parse(sessionStorage.DensityCorrection);
use_set_cache(); use_set_cache();
} }
keyDown()
window.onresize = () => { window.onresize = () => {
return (() => { return (() => {
if (div != null) { if (div != null) {
@ -1093,6 +1094,35 @@ export default defineComponent({
const handlerTouchend = () => { const handlerTouchend = () => {
clearInterval(loop) clearInterval(loop)
} }
/**
* 键盘监听
*/
const keyDown = () => {
document.onkeydown = (e) => {
let lock=0;
let e1 = e || window.event || arguments.callee.caller.arguments[0]
switch (e.code) {
case "KeyW":
now_v_h.value == 'vertical'?value_v.value[options_model_v.value].y++:""
break;
case "KeyA":
now_v_h.value != 'vertical'?value_h.value[options_model_h.value].x--:""
break;
case "KeyS":
now_v_h.value == 'vertical'?value_v.value[options_model_v.value].y--:""
break;
case "KeyD":
now_v_h.value != 'vertical'?value_h.value[options_model_h.value].x++:""
break;
default:
lock=1
break;
}
if(lock==0){
now_v_h.value != 'vertical'?chang(options_model_h.value, value_h.value[options_model_h.value].x, 'h'):chang(options_model_v.value, value_v.value[options_model_v.value].y, 'h')
}
}
}
defineExpose({ defineExpose({
now_v_h, now_v_h,
options_model_v, options_model_v,

View File

@ -376,6 +376,7 @@ export default defineComponent({
set_cache.value = JSON.parse(sessionStorage.FourPointCalibration); set_cache.value = JSON.parse(sessionStorage.FourPointCalibration);
use_set_cache(); use_set_cache();
}}) }})
keyDown()
window.onresize = () => { window.onresize = () => {
return (() => { return (() => {
if (div != null) { if (div != null) {
@ -518,6 +519,33 @@ export default defineComponent({
const handlerTouchend=()=>{ const handlerTouchend=()=>{
clearInterval(loop) clearInterval(loop)
} }
/**
* 键盘监听
*/
const keyDown = () => {
document.onkeydown = (e) => {
let lock=0;
let e1 = e || window.event || arguments.callee.caller.arguments[0]
switch (e.code) {
case "KeyW":
value.value[options_model.value].y++
break;
case "KeyA":
value.value[options_model.value].x--
break;
case "KeyS":
value.value[options_model.value].y--
break;
case "KeyD":
value.value[options_model.value].x++
break;
default:
lock=1
break;
}
if(lock==0)chang(options_model.value,"h", 'h')
}
}
defineExpose({ defineExpose({
options_model, options_model,
}); });

View File

@ -423,6 +423,7 @@ export default defineComponent({
set_cache.value = JSON.parse(sessionStorage.SurfaceCorrection); set_cache.value = JSON.parse(sessionStorage.SurfaceCorrection);
use_set_cache(); use_set_cache();
} }
keyDown()
window.onresize = () => { window.onresize = () => {
return (() => { return (() => {
if (div != null) { if (div != null) {
@ -755,6 +756,33 @@ export default defineComponent({
const handlerTouchend = () => { const handlerTouchend = () => {
clearInterval(loop) clearInterval(loop)
} }
/**
* 键盘监听
*/
const keyDown = () => {
document.onkeydown = (e) => {
let lock=0;
let e1 = e || window.event || arguments.callee.caller.arguments[0]
switch (e.code) {
case "KeyW":
value.value[options_model.value].y++
break;
case "KeyA":
value.value[options_model.value].x--
break;
case "KeyS":
value.value[options_model.value].y--
break;
case "KeyD":
value.value[options_model.value].x++
break;
default:
lock=1
break;
}
if(lock==0)chang(options_model.value,"h", 'h')
}
}
defineExpose({ defineExpose({
options_model, options_model,
}); });