/**
 * 检测键盘是否开启了大小写
 *
 * @format
 */
export const detectCapsLock = (event: React.KeyboardEvent<HTMLInputElement>) => {
    const e: React.KeyboardEvent<HTMLInputElement> | Event = event || window.event;
    const keyCode = e.keyCode || e.which; //解决兼容性问题(有些浏览器是keyCode有些浏览器是whitch)
    const isShift = e.shiftKey || keyCode == 16 || false; // shift键是否按住(shift按住，即使开启大写也是输入的小写)
    if (
        (keyCode >= 65 && keyCode <= 90 && !isShift) || // Caps Lock 打开，且没有按住shift键
        (keyCode >= 97 && keyCode <= 122 && isShift) // Caps Lock 打开，且按住shift键
    ) {
        return true;
    }
    return false;
};
