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

266
Vistas
How do I get the element that receives the keyboard input in web.whatsapp.com?

I want to provide handicapped users a way to operate web.whatsapp.com by keyboard only.

This works to some extent:

Users can jump around each tab and arrow keys.

Audio messages can be played / muted by pressing Space.

However, I have not found a way to open / large video or images:

enter image description here

Also, even I could find out which key opens / maximizes the images, I find it akward that my users would have to press 2 different keys

So the first thing I investigated was which element is currently active / selected.

My idea was to do the following (pseudo code)

if (UserPressedSomeSwitchToClickTheCurrentlySelectedElement)
    if (document.activeElement.type = 'wa-audio')
        SendSpace
    else if (document.activeElement.type = 'wa-Image') then
        'todo: investigate how to click this element
    

So the first thing I tried was to find out which element is the active one / the one which receives keyboard input.

To start off simple, I set the focus to the group search box and executed JS to tell me the element.

In this screenshot, one can see that the cursor is blinking in the group search box:

enter image description here

When I press the key "n" on my keyboard, it is printed in this element:

enter image description here

I have tried the following approaches to get the element which receives the input:

var e = document.activeElement;
if (e)
{
     alert('document.activeElement: ' + e + ', name: ' + e.name);
}
else
{
     alert('document.activeElement was nothing');
     e = document.querySelector(": focus");
     if (e)
     {
         alert('querySelector : focus: ' + e);
     }
     else
     {
         alert('querySelector : focus was nothing');
     }
}

The alert that I get is:

enter image description here

In some cases, e.className reveals a name.

When I am in the people selection tab on the left side however, e.className returns '', so I don't have any clue where I'm at.

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

0

Hope I understood you right. With this code you can perform a click on a selected image in WhatsApp Web.

document.querySelector('.focusable-list-item[tabindex="0"] img').dispatchEvent(new Event('click', {bubbles: true}))

The item with the class focusable-list-item ist selected. This is mostly everything in your chat, that you can access by key up/down. To qualify the selector I use [tabindex="0"] which gives only the active (blue background) chat item. From there we go deeper until we meet the <img> tag. We perform a click, which bubbles up to the specific element, which triggers the fullscreen mode.

For me it works fine in Firefox console. I have no clue if it will work with your VBA.

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