JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="textField" spellcheck="false" maxlength="6" />

JavaScript

document.getElementById('textField').addEventListener('keyup', function(e) {
    var keycode = e.keyCode || e.which
        // Allow: tab, home, end, left, up, right, down
    if ([9, 36, 35, 37, 38, 39, 40].indexOf(keycode) !== -1 ||
        // Allow: Ctrl || Command && a, c, x and v
        (!0 === e.ctrlKey || !0 === e.metaKey) && /65|67|88|86/.test(keycode)) {
        if (keycode === 86 && /(^[0-9A-F]{6}$)|(^[0-9A-F]{3}$)/i.test(e.target.value)) {
            console.log('Do Something with valid PASTED Hex Color');
        }
		console.log('Should return after this');
        return;
    }

    if (/^[0-9A-F]{6}$/i.test(e.target.value)) {
        console.log('Do Something with valid Hex Color');
    }
});