<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: LordGhapa</title>
    <description>The latest articles on DEV Community by LordGhapa (@lordghapa).</description>
    <link>https://dev.to/lordghapa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F856553%2Fd8aa7e6b-c6a1-4d2c-a296-bbf9a719455f.png</url>
      <title>DEV Community: LordGhapa</title>
      <link>https://dev.to/lordghapa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lordghapa"/>
    <language>en</language>
    <item>
      <title>can someone help me, I'm trying to simulate the click in the html only for specific keys</title>
      <dc:creator>LordGhapa</dc:creator>
      <pubDate>Mon, 02 May 2022 13:18:12 +0000</pubDate>
      <link>https://dev.to/lordghapa/can-someone-help-me-im-trying-to-simulate-the-click-in-the-html-only-for-specific-keys-1ppi</link>
      <guid>https://dev.to/lordghapa/can-someone-help-me-im-trying-to-simulate-the-click-in-the-html-only-for-specific-keys-1ppi</guid>
      <description>&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const mapaTeclado = {
  0: "tecla0", //class in html
  1: "tecla1",
  2: "tecla2",
};
const mapearTeclado = (evento) =&amp;gt; {
  const tecla = evento.key;
  console.log(evento.key);

  const teclaPermitida = () =&amp;gt; Object.keys(mapaTeclado).indexOf(tecla) != -1;
  if (teclaPermitida()) {
    // document.getElementsByClassName(mapaTeclado[tecla]).click();  dontwork
    // document.querySelector(mapateclado, "[class=tecla]").click(); dont work

    console.log("allowed key");
  }
};
document.addEventListener("keydown", mapearTeclado);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://github.com/LordGhapa/pequeno-estudo-em-js"&gt;https://github.com/LordGhapa/pequeno-estudo-em-js&lt;/a&gt;&lt;br&gt;
&lt;a href="https://lordghapa.github.io/pequeno-estudo-em-js/calculadora/"&gt;https://lordghapa.github.io/pequeno-estudo-em-js/calculadora/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
    </item>
  </channel>
</rss>
