function createFilter(key) {
    if (typeof key == 'function')
        return key;

    if (typeof key == 'string')
        return event => event.key === key;

    throw new TypeError('The filter must be either a string or a function');
}
// that tests if the event.key equals the key.
that tests if the event.key equals the key.
that tests if the event . key equals the key .
function createFilter(key) {
    if (typeof key == 'function')
        return key;
    if (typeof key == 'string')
        return event => event.key === key;
    throw new TypeError('The filter must be either a string or a function');
}
function createFilter ( key ) { if ( typeof key == 'function' ) return key ; if ( typeof key == 'string' ) return event => event . key === key ; throw new TypeError ( 'The filter must be either a string or a function' ) ; }
that tests if the event.key equals the key.
that tests if the event . key equals the key .