Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 26th, 2012  |  syntax: None  |  size: 0.87 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Cursor jumping to the end of text if edit made to previous text
  2. // This code checks for a certain keypress combo. For example cx, Cx, gx, Gx, etc...
  3. // The hard to type esperanto characters we aim to insert.
  4.  
  5. var esperanto = [
  6.     ['cx','u0109'],  ['gx','u011D'],
  7.     ['hx','u0125'],  ['jx','u0135'],
  8.     ['sx','u015D'],  ['ux','u016D'],
  9.  
  10.     ['Cx','u0108'],  ['Gx','u011C'],
  11.     ['Hx','u0124'],  ['Jx','u0134'],
  12.     ['Sx','u015C'],  ['Ux','u016C']
  13. ];
  14.  
  15. document.onkeyup = changeChars;
  16.  
  17. function changeChars(e) {
  18.     var KeyID = (window.event) ? event.keyCode : e.keyCode;
  19.     if(KeyID == 88)
  20.     {
  21.         var tmp = document.getElementById('TArea').value;
  22.         for (var i=0; i<esperanto.length; i++) {
  23.             re = new RegExp(esperanto[i][0],"g");
  24.             tmp = tmp.replace(re,esperanto[i][1]);
  25.         }
  26.         document.getElementById('TArea').value = tmp;
  27.     }  
  28. }