Use event.code instead of event.keyCode. Add key codes to default settings

This commit is contained in:
Tamius Han 2019-10-23 19:34:58 +02:00
parent cd4e3768e2
commit 261f9a6b8d
5 changed files with 45 additions and 49 deletions

View File

@ -191,6 +191,7 @@ var ExtensionConf = {
label: 'Automatic', // example override, takes precedence over default label label: 'Automatic', // example override, takes precedence over default label
shortcut: [{ shortcut: [{
key: 'a', key: 'a',
code: 'KeyA',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -216,6 +217,7 @@ var ExtensionConf = {
show: true, show: true,
shortcut: [{ shortcut: [{
key: 'r', key: 'r',
code: 'KeyR',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -241,6 +243,7 @@ var ExtensionConf = {
show: true, show: true,
shortcut: [{ shortcut: [{
key: 'w', key: 'w',
code: 'KeyW',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -266,6 +269,7 @@ var ExtensionConf = {
show: true, show: true,
shortcut: [{ shortcut: [{
key: 'e', key: 'e',
code: 'KeyE',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -292,6 +296,7 @@ var ExtensionConf = {
show: true, show: true,
shortcut: [{ shortcut: [{
key: 's', key: 's',
code: 'KeyS',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -318,6 +323,7 @@ var ExtensionConf = {
show: true, show: true,
shortcut: [{ shortcut: [{
key: 'd', key: 'd',
code: 'KeyD',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -344,6 +350,7 @@ var ExtensionConf = {
show: true, show: true,
shortcut: [{ shortcut: [{
key: 'x', key: 'x',
code: 'KeyX',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -369,6 +376,7 @@ var ExtensionConf = {
show: false, show: false,
shortcut: [{ shortcut: [{
key: 'z', key: 'z',
code: 'KeyY',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -393,6 +401,7 @@ var ExtensionConf = {
show: false, show: false,
shortcut: [{ shortcut: [{
key: 'u', key: 'u',
code: 'KeyU',
ctrlKey: false, ctrlKey: false,
metaKey: false, metaKey: false,
altKey: false, altKey: false,
@ -412,20 +421,6 @@ var ExtensionConf = {
action: 'toggle-pan', action: 'toggle-pan',
arg: 'toggle' arg: 'toggle'
}], }],
scopes: {
page: {
show: true,
shortcut: [{
key: 'p',
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
onKeyUp: true,
onKeyDown: false,
}]
}
},
playerUi: { playerUi: {
show: true, show: true,
path: 'zoom' path: 'zoom'

View File

@ -192,8 +192,8 @@ class ActionHandler {
shortcut.altKey === event.altKey && shortcut.altKey === event.altKey &&
shortcut.shiftKey === event.shiftKey shortcut.shiftKey === event.shiftKey
} }
isActionMatchKeycode(shortcut, event) { isActionMatchKeyCode(shortcut, event) {
return shortcut.keyCode === event.key && return shortcut.code === event.code &&
shortcut.ctrlKey === event.ctrlKey && shortcut.ctrlKey === event.ctrlKey &&
shortcut.metaKey === event.metaKey && shortcut.metaKey === event.metaKey &&
shortcut.altKey === event.altKey && shortcut.altKey === event.altKey &&
@ -205,7 +205,7 @@ class ActionHandler {
// regular matching by key is going to work // regular matching by key is going to work
return isLatin ? return isLatin ?
this.isActionMatchStandard(shortcut, event) : this.isActionMatchStandard(shortcut, event) :
this.isActionMatchStandard(shortcut, event) || this.isActionMatchKeycode(shortcut, event); this.isActionMatchStandard(shortcut, event) || this.isActionMatchKeyCode(shortcut, event);
} }
execAction(actions, event, videoData) { execAction(actions, event, videoData) {

View File

@ -109,6 +109,8 @@
</template> </template>
<script> <script>
import ControlsSettings from './controls-settings/ControlsSettings';
import GeneralSettings from './GeneralSettings';
import Donate from '../common/misc/Donate.vue'; import Donate from '../common/misc/Donate.vue';
import SuperAdvancedSettings from './SuperAdvancedSettings.vue'; import SuperAdvancedSettings from './SuperAdvancedSettings.vue';
import Debug from '../ext/conf/Debug.js'; import Debug from '../ext/conf/Debug.js';

View File

@ -39,12 +39,11 @@
</template> </template>
<script> <script>
import SetShortcutButton from './SetShortcutButton.vue'; import SetShortcutButton from './SetShortcutButton';
export default { export default {
components: { components: {
SetShortcutButton SetShortcutButton,
}, },
props: { props: {
scopeOptions: Object, scopeOptions: Object,

View File

@ -38,7 +38,7 @@ export default {
if (this.waitingForPress) { if (this.waitingForPress) {
const shortcut = { const shortcut = {
key: event.key, key: event.key,
keyCode: event.keyCode, code: event.code,
ctrlKey: event.ctrlKey, ctrlKey: event.ctrlKey,
metaKey: event.metaKey, metaKey: event.metaKey,
altKey: event.altKey, altKey: event.altKey,