Jump to content

User:V111P/js/Simple Keyboard Layout Changer

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by V111P (talk | contribs) at 12:55, 10 January 2012 (docs). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

Simple Keyboard Layout Changer — with this script you can transform the characters you type in the search and resume input boxes and in the textarea into different characters — for example, into characters from a different language.

The script supports multiple groups of characters to convert to and you can switch between the different groups with a click on a link.

Warning: When using this script, the 'undo' function doesn't work in Internet Explorer.

The script was tested (on Windows) with Firefox 6, Google Chrome 16, Safari 5, Internet Explorer 9.

WikEd is also supported.

Installation

To start the script, you need to include it in your common.js (or skin.js) and then call init() with the appropriate arguments. Here is an example:

$.getScript('//en.wikipedia.org/w/index.php?title=User:V111P/SKLChanger.js&action=raw',
  function() {
    sKLChanger.init({
      showLayoutHint: true, // see below for explanation
      charsToConvert: // The chars that will be converted:
      '' // empty string means "use the default one" (with the US layout, minus the numbers)
    });

    sKLChanger.addLayout(
      // short and long name of the layout:
      'Sy', 'Symbols',
      // chars
      '√←→' // with the default charsToConvert, this will convert ` to √,
            // - to  ←, and = to →. (the first three keys in the US layout are `-=).
    );

    // You can do as many sKLChanger.addLayout()'s as you like.
});

If showLayoutHint is set to true in init(), the symbols in the current layout are shown in a tool-tip window (presently through the title attribute) when the long-label indicator is under the pointer of the mouse. But this won't happen if you are using the Navigation popups gadget.

The default charsToConvert are:

'`-='
+ 'qwertyuiop[]\\'
+ 'asdfghjkl;\''
+ 'zxcvbnm,./'
// with shift
+ '~!@#$%^&*()_+'
+ 'QWERTYUIOP{}|'
+ 'ASDFGHJKL:"'
+ 'ZXCVBNM<>?';

One limitation is that Caps Lock doesn't have any effect on character keys and its state can't be detected with JavaScript. If you want to use a letter on a character key, Caps Lock will not work there.

See also