title: Keydown Javascript Function does not return false /exit on Mobile Platforms (code works for desktop)
body: <p>Hi i am very new to coding. I am trying to create a contenteditable div that is one line only and prevents the user typing more characters when the [contenteditable] reaches the same width as the parent element (e.g. i don't want it to overflow). The below code works on Desktop but not android or IOS. It seems there are 2 issues; 1) the return false; does not exit on android + IOS. 2) android + IOS do not recognise the &quot;e.which&quot; numbers...on android all keyboard letters are 229. My question is how do I get this code to work on mobile platforms please? Many thanks!</p>
  <p>Note: On android all keys are e.which = 229 except Delete = 8 and Enter = 13. The code returns for 8 &amp; 13 but not the rest 229.</p>
  <pre><code>&lt;div class=&quot;textarea&quot;&gt;
      
      &lt;div contenteditable class=&quot;global-text-field&quot;&gt;Lorum Ipsum&lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;style&gt;
  .global-text-field{position:absolute;  white-space: nowrap;}
  .textarea {position:relative; width:200px; height:50px; background:yellow;}
  &lt;/style&gt;
  
  
  &lt;script src=&quot;https://code.jquery.com/jquery-3.5.0.js&quot;&gt;&lt;/script&gt;
  &lt;script&gt;
  
          $('.global-text-field').on('keydown', function(e){
          return OverflowOneLine(e);   
          });    
              
          function OverflowOneLine(e){
             
              var left = parseFloat($(event.target).css('left'));
              var right = parseFloat($(event.target).css('right'));
  &lt;!--e.which 8 = Delete, 46 = Backspace, 37 = ArrowLeft, 39 = ArrowRight--&gt;
              if(right &lt;= 6 &amp;&amp; e.which !=46 &amp;&amp; e.which !=37 &amp;&amp; e.which !=39 &amp; e.which !=8){
                  return false;
              }
              
              return e.which != 13;
          }  
          
  &lt;/script&gt;
  </code></pre>