Pensi sia una buona soluzione il seguente codice?:
codice:
//[...]
_onselect : function(element) {
var form = new Element('form');
form.name = "cellEdit";
var input = new Element('input');
input.type = "text";
input.value = "inserisci un testo";
element.update();
element.insert(form);
form.insert(input);
input.focus();
input.onkeydown = this._onkey.bindAsEventListener(this);
},
_onkey: function(event) {
if(event.keyCode == 13)
alert("tasto premuto: INVIO");
},
//[...]
In un altro topic ho letto di un ragazzo che ha risolto in questo modo:
codice:
if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {
alert('invio eseguito')
}
Cosa fanno questi controlli? .which?
(non capisco perchè non ha fatto semplicemente "if(event.keyCode == 13)" )