feat: 添加按住Alt+数字键快速选择的功能

This commit is contained in:
ZiuChen 2022-08-25 22:10:54 +08:00
parent 0c84471671
commit f707ac41f1

View File

@ -81,11 +81,12 @@ watch(
onMounted(() => {
//
document.addEventListener('keydown', (e) => {
const { key, ctrlKey, metaKey } = e
const { key, ctrlKey, metaKey, altKey } = e
const isArrowUp = key === 'ArrowUp'
const isArrowDown = key === 'ArrowDown'
const isEnter = key === 'Enter'
const isCopy = (ctrlKey || metaKey) && (key === 'C' || key === 'c')
const isNumber = key === '1' || '2' || '3' || '4' || '5' || '6' || '7' || '8' || '9'
if (isArrowUp) {
if (activeIndex.value > 0) {
activeIndex.value--
@ -113,6 +114,9 @@ onMounted(() => {
} else if (isEnter) {
window.copy(props.showList[activeIndex.value])
window.paste()
} else if (altKey && isNumber) {
window.copy(props.showList[parseInt(key)])
window.paste()
}
})
})