Div Comtenediate MaxLength ReactJs

const maxLength = 12
const onKeyDwn = (e: any) => {
        const currentTextLength = e.target.outerText.length;
        if (currentTextLength === maxLength && e.keyCode != 8) {
            e.preventDefault();
        }
}


<div onKeyDown={onKeyDwn} contentEditable={true} ></div>
SamuraiR4cc00n