调整快捷键

This commit is contained in:
purocean
2021-01-17 00:17:17 +08:00
parent 8bb86baacc
commit 5c5f9e3290
2 changed files with 5 additions and 4 deletions
+2 -2
View File
@@ -27,6 +27,8 @@ const actions = {
type ActionName = keyof typeof actions
export const hasCtrlCmd = (e: KeyboardEvent | MouseEvent) => isMacOS ? e.metaKey : e.ctrlKey
export const getKeyLabel = (key: XKey | string | number) => {
switch (key) {
case CtrlCmd:
@@ -45,8 +47,6 @@ export const getActionLabel = (name: ActionName) => {
return keys.map(getKeyLabel).join(' + ')
}
export const hasCtrlCmd = (e: KeyboardEvent | MouseEvent) => isMacOS ? e.metaKey : e.ctrlKey
export const matchKeys = (e: KeyboardEvent | MouseEvent, keys: (string | number)[]) => {
for (const key of keys) {
switch (key) {
+3 -2
View File
@@ -3,6 +3,7 @@ import { useBus } from './bus'
import RunPlugin from '@/plugins/RunPlugin'
import { copyText } from './copy-text'
import env from './env'
import { hasCtrlCmd } from './shortcut'
export default function startup () {
const bus = useBus()
@@ -35,7 +36,7 @@ export default function startup () {
}
window.addEventListener('keydown', e => {
if (e.ctrlKey || e.metaKey) {
if (hasCtrlCmd(e)) {
if (e.key === '0') {
webContents.setZoomFactor(1)
} else if (e.key === '=') {
@@ -49,7 +50,7 @@ export default function startup () {
window.addEventListener('mousewheel', event => {
const e = event as WheelEvent
if (e.ctrlKey || e.metaKey) {
if (hasCtrlCmd(e)) {
changeZoomFactor(e.deltaY < 0)
}
})