How to use the nav-frontend-js-utils.keyCodes.right function in nav-frontend-js-utils

To help you get started, we’ve selected a few nav-frontend-js-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github navikt / nav-frontend-moduler / packages / node_modules / nav-frontend-tabs / src / tabs-pure.tsx View on Github external
handleKeyDown = (e) => {
        let newIndex;
        const modifier = (!this.props.arrowKeysAutoSwitchTabs) ? this.focusIndex : this.aktivIndex ;
        const keyCode = e.keyCode || e.which;
        switch (keyCode) {
            case keyCodes.right:
                newIndex = (modifier < (this.getNumTabs() - 1)) ? modifier + 1 : 0 ;
                break;
            case keyCodes.left:
                newIndex = (modifier > 0) ? modifier - 1 : this.getNumTabs() - 1 ;
                break;
        }

        if (newIndex === undefined) return;

        if (!this.props.arrowKeysAutoSwitchTabs) {
            this.linkRefs[newIndex].focus();
        } else {
            if (typeof this.props.onChange === 'function') this.props.onChange(e, newIndex);
        }
    }