Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

147
Visualizações
onKeyPress eventlistener not working after focusing on iframe (Reactjs)

i've got a problem that don't know how to deal with. I'm using HCaptcha component for verification and after the user clicks on the checkbox in order to verify, my 'keydown' eventListener does not work anymore. apparantly the problem is that HCaptcha is rendering in iframe and the page loses focus after checking it. Any one got any ideas? Thanks for your help.

     useEffect(() => {
        const listener = event => {
            if (event.code === 'Enter' || event.code === 'NumpadEnter') {
                event.preventDefault();
                btnRef.current?.click();
            }
        };
        document.addEventListener('keydown', listener);
        return () => {
            document.removeEventListener('keydown', listener);
        };
    }, []);

     return (
                    <div className="auth-footer">
                        <HCaptcha
                            sitekey={window._env_.hCaptchaSiteKey}
                            onVerify={token => {
                                setCapchaToken(token);
                                formRef.current?.focus();
                            }}
                            ref={captchaRef}
                        />
                        <div className="tw-my-6">
                            <Button
                                ref={btnRef}
                                type="button"
                                disabled={formValidation()}
                                onClick={handleSubmit}
                                loading={loading}
                                className="btn reset-password-submit">
                                ارسال کد
                            </Button>
                        </div>
                    </div>
)
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda