title: Create a backspace button for html/javascript-based textarea
body: <p>I have a created a virtual keyboard to decipher a puzzle code on a html/java page, however I am unable to work out how to add a backspace or linebreak button to avoid having to mouseclick the textarea to backspace every time a single mistake is made or need a new line.</p>
  
  <p>Code for the page is added below, any ideas to do this as simply as possible would be greatly appreciated, as I'm still learning Javascript and havent quite got my head around some events yet.</p>
  
  <p>Thanks in advance.</p>
  
  <pre><code>&lt;!DOCTYPE HTML&gt;
   &lt;HTML&gt;
   &lt;head&gt;
  &lt;!--JQuery activation--&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"&gt;&lt;/script&gt;
  
  
  &lt;div class="container-fluid"&gt;
  &lt;div class="col-md-8"&gt;
  
  &lt;div id="letters"&gt;
  &lt;!-- PLCKFBG HMOERJ AQNXYIZ VWSUT,.123456789O (and space) cypher alphabet--&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="P" style="width:100%"  id="A" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="L" style="width:100%"  id="B" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="C" style="width:100%"  id="C" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="K" style="width:100%"  id="D" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="F" style="width:100%"  id="E" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="B" style="width:100%"  id="F" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="G" style="width:100%"  id="G" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="D" style="width:100%"  id="H" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="H" style="width:100%"  id="I" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="M" style="width:100%"  id="J" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="O" style="width:100%"  id="K" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="E" style="width:100%"  id="L" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="R" style="width:100%"  id="M" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="J" style="width:100%"  id="N" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="A" style="width:100%"  id="O" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="Q" style="width:100%"  id="P" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="N" style="width:100%"  id="Q" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="X" style="width:100%"  id="R" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="Y" style="width:100%"  id="S" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="I" style="width:100%"  id="T" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="Z" style="width:100%"  id="U" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="V" style="width:100%"  id="V" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="W" style="width:100%"  id="W" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="S" style="width:100%"  id="X" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="U" style="width:100%"  id="Y" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="T" style="width:100%"  id="Z" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="." style="width:100%"  id="." /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="," style="width:100%"  id="," /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="1" style="width:100%"  id="1" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="2" style="width:100%"  id="2" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="3" style="width:100%"  id="3" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="4" style="width:100%"  id="4" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="5" style="width:100%"  id="5" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="6" style="width:100%"  id="6" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="7" style="width:100%"  id="7" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="8" style="width:100%"  id="8" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="9" style="width:100%"  id="9" /&gt;
  &lt;input type="submit" style="font-family:'Wingdings'" value="A" style="width:100%"  id="O" /&gt;
  &lt;input type="submit" style="font-family:'Copperplate'" value="[Space]" style="width:100%"  id=" " /&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div class="col-md-4"&gt;
  
  &lt;!-- Clear button --&gt;
  &lt;div id="clearbutton"&gt;   
  &lt;input type="button" value="Clear" onclick="javascript:eraseText();"&gt; 
  &lt;/div&gt;
  
  &lt;!-- textarea "translation"--&gt;
  &lt;textarea id="translation" class="form control ChangeMe" name="translation" rows=10 cols=50 placeholder="Common Translation"&gt;&lt;/textarea&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  
  
  &lt;script&gt;
  // code for letter translation
  $(document).ready(function(){
    var txt=$('#translation');
    $("#letters").on('click','input',function() {
      txt.val(txt.val()+this.id);
    });
   });
  
  
  //Clear Button Function 
  function eraseText() {
  document.getElementById("translation").value = "";
  }
  
  //disable backspace outside of text boxes
  $(document).keydown(function (e) {
                  var element = e.target.nodeName.toLowerCase();
                  if ((element != 'input' &amp;&amp; element != 'textarea') || $(e.target).attr("readonly") || (e.target.getAttribute("type") ==="checkbox")) {
                      if (e.keyCode === 8) {
                      return false;
                      }
                  }
  });
  &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>