diff --git a/src/utils.js b/src/utils.js index 1a6aaee..2a41082 100644 --- a/src/utils.js +++ b/src/utils.js @@ -211,6 +211,11 @@ function applyShellStylesheet(stylesheet) { logDebug('Shell stylesheet applied.'); } +/** + * Check if the given keyval is forbidden. + * @param {number} keyval The keyval number. + * @returns {boolean} `true` if the keyval is forbidden. + */ function isKeyvalForbidden(keyval) { const forbiddenKeyvals = [ Gdk.KEY_Home, @@ -229,6 +234,12 @@ function isKeyvalForbidden(keyval) { return forbiddenKeyvals.includes(keyval); } +/** + * Check if the given key combo is a valid binding + * @param {{mask: number, keycode: number, keyval:number}} combo An object + * representing the key combo. + * @returns {boolean} `true` if the key combo is a valid binding. + */ function isBindingValid({ mask, keycode, keyval }) { if ((mask === 0 || mask === Gdk.SHIFT_MASK) && keycode !== 0) { if ( @@ -250,6 +261,12 @@ function isBindingValid({ mask, keycode, keyval }) { return true; } +/** + * Check if the given key combo is a valid accelerator. + * @param {{mask: number, keyval:number}} combo An object representing the key + * combo. + * @returns {boolean} `true` if the key combo is a valid accelerator. + */ function isAccelValid({ mask, keyval }) { return Gtk.accelerator_valid(keyval, mask) || (keyval === Gdk.KEY_Tab && mask !== 0); }