<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why map is focused on keydown.enter in input field? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1040691#M72204</link>
    <description>&lt;P&gt;I think the form element is setup to go when the enter key is identified.&amp;nbsp; You could possibly set up a routine to identify any key down/press event and determine if it's an enter key, such as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function onKeyDown(event) {
    // Shift key
    if (event.which === 16) { console.log('shift key pressed'); }
    else if (event.which === 27) { console.log('escape key pressed');}
    else if (event.which === 39 || event.which === 37) { 
        console.log('arrow keys pressed');
    }
    else if (event.which === 13) { 
        // Peform the function that you need, or disregard it.
        console.log('Enter key!');
    }
}&lt;/LI-CODE&gt;&lt;P&gt;but this can get ugly, fast.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would recommend that you don't setup, whatever it is that you are setting up, in a form.&amp;nbsp; Just have the input elements and set up an onclick event for the button to do something at that point.&amp;nbsp; Such as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;btnSubmit = document.getElementById("btnSubmit");
btnSubmit.onclick = function () {
    let val1 = document.getElementById("textbox1").value;
    let val2 = document.getElementById("textbox2").value;
    // Do something with these values...
}&lt;/LI-CODE&gt;&lt;P&gt;You'll need 'id' values in your elements but this should work.&amp;nbsp; Also, 'document.getElementById' is old school, but you could also import the Dojo 'dom' and use 'byId' that way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Mar 2021 17:27:58 GMT</pubDate>
    <dc:creator>JeffreyWilkerson</dc:creator>
    <dc:date>2021-03-25T17:27:58Z</dc:date>
    <item>
      <title>Why map is focused on keydown.enter in input field?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1040521#M72188</link>
      <description>&lt;P&gt;A form outside of map view loses focus on the enter key and the map is focused instead. I believe this behavior is not expected, and I am not sure if it is a bug or there is any way to avoid it.&lt;/P&gt;&lt;P&gt;Repro steps:&lt;/P&gt;&lt;OL class="ak-ol"&gt;&lt;LI&gt;&lt;P&gt;Open&amp;nbsp;&lt;A title="https://stackblitz.com/edit/js-pusl6y?file=index.html" href="https://stackblitz.com/edit/js-pusl6y?file=index.html" target="_blank" rel="noopener"&gt;https://stackblitz.com/edit/js-pusl6y?file=index.html&lt;/A&gt;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Enter value in form input above map&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Hit enter&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;Map search input field is focused&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Tested in Google Chrome 89.0.4389.82 with versions 4.16 and 4.18&lt;/P&gt;&lt;P&gt;Any ideas? Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 08:40:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1040521#M72188</guid>
      <dc:creator>martinparanor</dc:creator>
      <dc:date>2021-03-25T08:40:55Z</dc:date>
    </item>
    <item>
      <title>Re: Why map is focused on keydown.enter in input field?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1040691#M72204</link>
      <description>&lt;P&gt;I think the form element is setup to go when the enter key is identified.&amp;nbsp; You could possibly set up a routine to identify any key down/press event and determine if it's an enter key, such as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;function onKeyDown(event) {
    // Shift key
    if (event.which === 16) { console.log('shift key pressed'); }
    else if (event.which === 27) { console.log('escape key pressed');}
    else if (event.which === 39 || event.which === 37) { 
        console.log('arrow keys pressed');
    }
    else if (event.which === 13) { 
        // Peform the function that you need, or disregard it.
        console.log('Enter key!');
    }
}&lt;/LI-CODE&gt;&lt;P&gt;but this can get ugly, fast.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would recommend that you don't setup, whatever it is that you are setting up, in a form.&amp;nbsp; Just have the input elements and set up an onclick event for the button to do something at that point.&amp;nbsp; Such as:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;btnSubmit = document.getElementById("btnSubmit");
btnSubmit.onclick = function () {
    let val1 = document.getElementById("textbox1").value;
    let val2 = document.getElementById("textbox2").value;
    // Do something with these values...
}&lt;/LI-CODE&gt;&lt;P&gt;You'll need 'id' values in your elements but this should work.&amp;nbsp; Also, 'document.getElementById' is old school, but you could also import the Dojo 'dom' and use 'byId' that way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Mar 2021 17:27:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1040691#M72204</guid>
      <dc:creator>JeffreyWilkerson</dc:creator>
      <dc:date>2021-03-25T17:27:58Z</dc:date>
    </item>
    <item>
      <title>Re: Why map is focused on keydown.enter in input field?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1041440#M72244</link>
      <description>&lt;P&gt;Thank you, in the end I set up an override on document events and simply skipped events that took the focus.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 07:43:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/why-map-is-focused-on-keydown-enter-in-input-field/m-p/1041440#M72244</guid>
      <dc:creator>martinparanor</dc:creator>
      <dc:date>2021-03-29T07:43:46Z</dc:date>
    </item>
  </channel>
</rss>

