Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

176
Vistas
How to show a div when the enter key has been pressed in two textareas?

How do you detect that the enter key was pressed in two textareas? I have a way to detect the enter key was pressed in one textarea and need help with detecting the enter key was pressed in two textareas.

This is what I've done so far:

$('#test1').keyup(function(e) {
   if(e.keyCode == 13) {
        $("#GFG_DOWN").text("Enter key pressed inside textarea");
   }
});  
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id="test1"></textarea>
        <textarea id="test2"></textarea>
        <br>     
          
        <p id = "GFG_DOWN" style = 
            "color:green; font-size: 20px; font-weight: bold;">
        </p>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I guess you must handle this with two FlagVariables.

let text1Flag = false;
let text2Flag = false;

function callbackHandler(e, textType) {
   if(e.keyCode == 13) {
        if (textType == 1) {
            text1Flag = true;
        } else {
            text2Flag = true;
        }
        if (text1Flag && text2Flag) {
           $("#GFG_DOWN").text("Enter key pressed inside textarea");
            text1Flag = false;
            text2Flag = false;
        }
   }
}

$("#test1").keyup((ev) => callbackHandler(ev, 1));
$("#test2").keyup((ev) => callbackHandler(ev, 2));
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<textarea id="test1"></textarea>
        <textarea id="test2"></textarea>
        <br>     
          
        <p id = "GFG_DOWN" style = 
            "color:green; font-size: 20px; font-weight: bold;">
        </p>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda