odoo-13.0/addons/web/static/tests/helpers/test_utils_fields.js
/**
 * Helper to trigger a key event on an element.
 *
 * @param {string} type type of key event ('press', 'up' or 'down')
 * @param {jQuery} $el
 * @param {number|string} keyCode used as number, but if string, it'll check if
 *   the string corresponds to a key -otherwise it will keep only the first
 *   char to get a letter key- and convert it into a keyCode.
 * @returns {Promise}
 */
Helper to trigger a key event on an element.
Helper to trigger a key event on an element .
function triggerKey(type, $el, keyCode) {
    type = 'key' + type;
    if (typeof keyCode === 'string') {
        if (keyCode.length > 1) {
            keyCode = keyCode.toUpperCase();
            keyCode = $.ui.keyCode[keyCode];
        } else {
            keyCode = keyCode.charCodeAt(0);
        }
    }
    $el.trigger({type: type, which: keyCode, keyCode: keyCode});
    return concurrency.delay(0);
}
function triggerKey ( type , $el , keyCode ) { type = 'key' + type ; if ( typeof keyCode === 'string' ) { if ( keyCode . length > 1 ) { keyCode = keyCode . toUpperCase ( ) ; keyCode = $ . ui . keyCode [ keyCode ] ; } else { keyCode = keyCode . charCodeAt ( 0 ) ; } } $el . trigger ( { type : type , which : keyCode , keyCode : keyCode } ) ; return concurrency . delay ( 0 ) ; }
Helper to trigger a key event on an element.
Helper to trigger a key event on an element .