Главная » 2010 » Январь » 10 » Экранная клавиатура (Javascript)
10.01.2010, 10:27

Экранная клавиатура



Скрипт экранной клавиатуры с основными клавишами.

Это ставим в head:

Code
<script language="JavaScript"><!-- Start
   
var lineHTML = "";
var lock = 1;
var uca = 0;
var initial = 0;
var filter = /[a-z]/

function rkey()
{
lineHTML = "";
this.disp.value = lineHTML;
}

function skey(i) // GroЯschreibung
{
if (i == "uc")
{
uca = 1;
this.capsdisp.value = "Abc";
}

if (i == "caps")
{
lock = (lock * -1);
if (lock < 0)
{
this.lockdisp.value = "ABC";
}
if (lock > 0)
{
this.lockdisp.value = "";
}
}
}

function zkey(i) // Zeichen
{
if ((i == ",") && (uca == 1))
{
i = ";"
}
if ((i == ".") && (uca == 1))
{
i = ":"
}
if ((i == "-") && (uca == 1))
{
i = "_"
}
if ((i == "+") && (uca == 1))
{
i = "*"
}
lineHTML += i;
this.disp.value = lineHTML;
uca = 0;
this.capsdisp.value = "";
}

function ukey(i)
{
if ((i == "д") && ((uca == 1) || (lock < 0)))
{
i = "Д";
}
if ((i == "ц") && ((uca == 1) || (lock < 0)))
{
i = "Ц";
}
if ((i == "ь") && ((uca == 1) || (lock < 0)))
{
i = "Ь";
}

lineHTML += i;
this.disp.value = lineHTML;
uca = 0;
this.capsdisp.value = "";
}

function nkey(i) // normale Zeichen
{

if ((uca == 1) && (filter.test(i)))
{
i = i.toUpperCase();
}
if ((lock < 0) && (filter.test(i)))
{
i = i.toUpperCase();
}
lineHTML += i;
this.disp.value = lineHTML;
uca = 0;
this.capsdisp.value = "";
}

function fkey(i) {
//alert("Funktionstaste!");
if (i == "bs")
{
lineHTML = lineHTML.slice(0, (lineHTML.length-1));
}
this.disp.value = lineHTML;
}

function ekey()
{
// alert("der Ausdruck " + lineHTML + " wird abgeschickt");
opener.vollsuche.test.value = lineHTML;

window.close();
}

</SCRIPT>
   
<style>
.cabutt
{background-color: grey; color: black; width: 100%; height: 26;  
  position: relative; border-style: outset; border-color: whitesmoke}
</style>

Это в body:

Code
<table border="0" cellspacing="0" cellpadding="1">
  <tr>
  <td colspan=12>
  <center>
  <input type="text" name="disp" size="60" maxlength="90" value=" ">
  </center>
  </td>
  </tr>
  <tr>
  <td colspan=12>
   
  </td>
  </tr>
   
  <tr>
  <td>
  <input class="cabutt" type=button value="   1   " onClick="nkey(1)">
  </td>
  <td >
  <input class="cabutt" type=button value="   2   " onClick="nkey(2)">
  </td>
  <td >
  <input class="cabutt" type=button value="   3   " onClick="nkey(3)">
  </td>
  <td >
  <input class="cabutt" type=button value="   4   " onClick="nkey(4)">
  </td>
  <td >
  <input class="cabutt" type=button value="   5   " onClick="nkey(5)">
  </td>
  <td >
  <input class="cabutt" type=button value="   6   " onClick="nkey(6)">
  </td>
  <td >
  <input class="cabutt" type=button value="   7   " onClick="nkey(7)">
  </td>
  <td >
  <input class="cabutt" type=button value="   8   " onClick="nkey(8)">
  </td>
  <td >
  <input class="cabutt" type=button value="   9   " onClick="nkey(9)">
  </td>
  <td >
  <input class="cabutt" type=button value="   0   " onClick="nkey(0)">
  </td>
  <td colspan=2>
  <input class="cabutt" type=button value="   ←   " onClick="fkey('bs')">
  </td>
  </tr>
  <tr>
  <td>
  <input class="cabutt" type=button value="   Q   " onClick="nkey('q')">
  </td>
  <td >
  <input class="cabutt" type=button value="   W   " onClick="nkey('w')">
  </td>
  <td >
  <input class="cabutt" type=button value="   E   " onClick="nkey('e')">
  </td>
  <td >
  <input class="cabutt" type=button value="   R   " onClick="nkey('r')">
  </td>
  <td >
  <input class="cabutt" type=button value="   T   " onClick="nkey('t')">
  </td>
  <td >
  <input class="cabutt" type=button value="   Z   " onClick="nkey('z')">
  </td>
  <td >
  <input class="cabutt" type=button value="   U   " onClick="nkey('u')">
  </td>
  <td >
  <input class="cabutt" type=button value="   I   " onClick="nkey('i')">
  </td>
  <td >
  <input class="cabutt" type=button value="   O   " onClick="nkey('o')">
  </td>
  <td >
  <input class="cabutt" type=button value="   P   " onClick="nkey('p')">
  </td>
  <td >
  <input class="cabutt" type=button value="   Ь   " onClick="ukey('ь')">
  </td>
  <td >
  <input class="cabutt" type=button value="   +   " onClick="zkey('+')">
  </td>
  </tr>
  <tr>
  <td >
  <input class="cabutt" type=button value="Caps" onClick="skey('caps')">
   
  </td>
  <td>
  <input class="cabutt" type=button value="   A   " onClick="nkey('a')">
  </td>
  <td >
  <input class="cabutt" type=button value="   S   " onClick="nkey('s')">
  </td>
  <td >
  <input class="cabutt" type=button value="   D   " onClick="nkey('d')">
  </td>
  <td >
  <input class="cabutt" type=button value="   F   " onClick="nkey('f')">
  </td>
  <td >
  <input class="cabutt" type=button value="   G   " onClick="nkey('g')">
  </td>
  <td >
  <input class="cabutt" type=button value="   H   " onClick="nkey('h')">
  </td>
  <td >
  <input class="cabutt" type=button value="   J   " onClick="nkey('j')">
  </td>
  <td >
  <input class="cabutt" type=button value="   K   " onClick="nkey('k')">
  </td>
  <td >
  <input class="cabutt" type=button value="   L   " onClick="nkey('l')">
  </td>
  <td >
  <input class="cabutt" type=button value="   Ц   " onClick="ukey('ц')">
  </td>
  <td >
  <input class="cabutt" type=button value="   Д   " onClick="ukey('д')">
  </td>
  </tr>
  <tr>
  <td colspan=2>
  <input class="cabutt" type=button value="   ↑   " onClick="skey('uc')">
  </td>
  <td>
  <input class="cabutt" type=button value="   Y   " onClick="nkey('y')">
  </td>
  <td >
  <input class="cabutt" type=button value="   X   " onClick="nkey('x')">
  </td>
  <td >
  <input class="cabutt" type=button value="   C   " onClick="nkey('c')">
  </td>
  <td >
  <input class="cabutt" type=button value="   V   " onClick="nkey('v')">
  </td>
  <td >
  <input class="cabutt" type=button value="   B   " onClick="nkey('b')">
  </td>
  <td >
  <input class="cabutt" type=button value="   N   " onClick="nkey('n')">
  </td>
  <td >
  <input class="cabutt" type=button value="   M   " onClick="nkey('m')">
  </td>
  <td >
  <input class="cabutt" type=button value="   ,   " onClick="zkey(',')">
  </td>
  <td >
  <input class="cabutt" type=button value="   .   " onClick="zkey('.')">
  </td>
  <td >
  <input class="cabutt" type=button value="   -   " onClick="zkey('-')">
  </td>
  </tr>
  <tr>
  <td>
  <center>
  <input type="text" name="capsdisp" size="3" maxlength="4" value="">
  </center>
  </td>
  <td>
  <center>
  <input type="text" name="lockdisp" size="3" maxlength="4" value=" ">
  </center>
  </td>
  <td colspan=8>
  <input class="cabutt" type=button value=" " onClick="nkey(' ')">
  </td>
  <td colspan=2>
  <input class="cabutt" type=button value="Enter" onClick="ekey()">
  </td>
  </tr>
  </table>
Материал взят с сайта infoscript.ru
Внимание! Копирование данного материала запрещено без указания ссылки на сайт Infoscript.ru
Источник/Автор: Неизвестен
Категория: JavaScript's | Просмотров: 4863 | Добавил: antisept | Рейтинг: 4.0/1 |
Теги: клавиатура, экранная
Пока комментариев нет. Ты можешь быть первым!
Добавлять комментарии могут только зарегистрированные пользователи.
[ Регистрация | Вход ]