renderer/utils/helpers.js
/**
 * Callback to assign functions to keys in a keydown event
 * @param {string|array|object} codes
 * @param {function} callback
 */
Callback to assign functions to keys in a keydown event
@param {string|array|object} codes
@param {function} callback
Callback to assign functions to keys in a keydown event @param { string|array|object } codes @param { function } callback
function key(codes, callback) {
    if (typeof codes === 'string') {
        codes = [
            {
                keys: codes.split(','),
                callback
            }
        ];
    } else if (typeof codes === 'object') {
        codes = Object.keys(codes).map(keys => ({
            keys: keys.split(','),
            callback: codes[keys]
        }));
    }
    return event => {
        codes.forEach(code => {
            if (code.keys.includes(event.code)) {
                code.callback(event);
            }
        });
    };
}
function key ( codes , callback ) { if ( typeof codes === 'string' ) { codes = [ { keys : codes . split ( ',' ) , callback } ] ; } else if ( typeof codes === 'object' ) { codes = Object . keys ( codes ) . map ( keys => ( { keys : keys . split ( ',' ) , callback : codes [ keys ] } ) ) ; } return event => { codes . forEach ( code => { if ( code . keys . includes ( event . code ) ) { code . callback ( event ) ; } } ) ; } ; }
Callback to assign functions to keys in a keydown event
 @param {string|array|object} codes
 @param {function} callback
Callback to assign functions to keys in a keydown event @param { string|array|object } codes @param { function } callback