Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Josef Gabrielsson committed Jun 2, 2024
1 parent 7772c18 commit 68042bd
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions nightly/modules/keyboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@ app.module.keyboard = {
},

_keypressed: function (e) {
var bodyScope = document.activeElement === document.body ? 'body' : false

for (var i = 0; i < this.keys.length; i++) {
var current = this.keys[i]
if (e.key === current.key) {
var action = current.action,
element = current.element,
bodyScope = document.activeElement === document.body ? 'body' : false
currentScope = current.scope === '' ? 'body' : current.scope

if (bodyScope !== current.scope && current.scope) continue
if (bodyScope !== currentScope) continue

switch (action) {
case 'click':
Expand All @@ -45,13 +47,17 @@ app.module.keyboard = {
}
},

/**
* @function key
* @memberof app.module.keyboard
* @param {HTMLElement} element - The element with keyboard attributes to add.
* @description Adds a new keyboard action to the keys array.
*/
key: function (element) {
var key = element.getAttribute('keyboard-key'),
action = element.getAttribute('keyboard-action'),
scope = element.getAttribute('keyboard-scope')

dom.setUniqueId(element, true)

this.keys.push({ key: key, action: action, scope: scope, element: element })
},
}

0 comments on commit 68042bd

Please sign in to comment.