he encontrado este script que parece un movil y he visto que funciona la tecla \ n para salto de carro.
Para acabrlo, necesitaría una tecla que retrocediera y borrara el ultimo registro insertado.
Para pulirlo si tambien me dijerais unas teclas para desplazarme a la derecha o hacia la izquierda, seria tremendo.
Código PHP:
<html>
<head>
<script type="text/javascript">
var keys = new Array();
keys['1'] = new Object();
keys['1'].ctr = 0;
keys['1'].char = ['@',' ','1'];
keys['2'] = new Object();
keys['2'].ctr = 0;
keys['2'].char = ['a','b','c','2'];
keys['3'] = new Object();
keys['3'].ctr = 0;
keys['3'].char = ['d','e','f','3'];
keys['4'] = new Object();
keys['4'].ctr = 0;
keys['4'].char = ['g','h','i','4'];
keys['5'] = new Object();
keys['5'].ctr = 0;
keys['5'].char = ['j','k','l','5'];
keys['6'] = new Object();
keys['6'].ctr = 0;
keys['6'].char = ['m','n','ñ','o','6'];
keys['7'] = new Object();
keys['7'].ctr = 0;
keys['7'].char = ['p','q','r','7'];
keys['8'] = new Object();
keys['8'].ctr = 0;
keys['8'].char = ['s','t','u','8'];
keys['9'] = new Object();
keys['9'].ctr = 0;
keys['9'].char = ['\b']; // No funciona y no retrocede
keys['0'] = new Object();
keys['0'].ctr = 1;
keys['0'].char = ['\n']; // salto de carro
//and so on...
var append=false;
var str='';
var timer;
var prevNum=null;
function keypad(num){
var lcd = document.myform.lcd;
if (prevNum!=null && prevNum!=num) append=true;
if (keys[num].ctr>keys[num].char.length-1) keys[num].ctr=0; //go back to first item in keypad
if (append) {
str=lcd.value+keys[num].char[keys[num].ctr];
}
else {
str=(lcd.value.length==0) ? lcd.value=keys[num].char[keys[num].ctr]:lcd.value.substring(0,lcd.value.length-1)+keys[num].char[keys[num].ctr];
}
lcd.value=str;
keys[num].ctr++;
prevNum=num;
//reset
append=false;
clearTimeout(timer);
timer=setTimeout(function(){append=true;lcd.focus()}, 3000);
}
</script>
</head>
<body>
<form name="myform">
<p>
<textarea name="lcd" cols="50" rows="10"></textarea>
</p>
<p>
<input type="button" value="1" onclick="keypad('1')">
<input type="button" value="2" onclick="keypad('2')">
<input type="button" value="3" onclick="keypad('3')">
</P>
<p>
<input type="button" value="4" onclick="keypad('4')">
<input type="button" value="5" onclick="keypad('5')">
<input type="button" value="6" onclick="keypad('6')">
</p><p>
<input type="button" value="7" onclick="keypad('7')">
<input type="button" value="8" onclick="keypad('8')">
<input type="button" value="9<" onclick="keypad('9')">
</p><p>
<input type="button" value="salto" onclick="keypad('0')">
</p>
</form>
</body>
</html>