Eventuali duplicati:
Javascript capture keyRileva immettere tasto premuto utilizzando JavaScript
su cui sto lavorando funzione di risposta utilizzando MySQL e PHP.
mio db MySQL:
reply:
rid - id;
topicid - under which topic;
uid - id of the guy who replies;
content - what did the guy said.
Ecco il mio codice html:
<form id="replyform">
<textarea name="rplcont" placeholder="Press enter to submit your reply."><textarea>
</form>
La mia domanda è: come faccio a sapere se il tasto viene premuto entrare?
Molte grazie.
/-------------------------------------------- -/
ecco i miei codici che funzionano:
html:
<textarea id="reply" name="reply" onKeyPress="enterpressalert(event, this)"></textarea>
js:
function enterpressalert(e, textarea){
var code = (e.keyCode ? e.keyCode : e.which);
if(code == 13) { //Enter keycode
alert('enter press');
}
}
e funziona.
Grazie per tutti coloro che riguardano questo argomento!
Dups ovunque! http://stackoverflow.com/search?q=enter+key+javascript – elclanrs
Troverai informazioni correlate qui: http://stackoverflow.com/questions/239082/javascript-login-form-doesnt-submit-when-user -hits-enter –
@VishalSuthar: Grazie, sei davvero generoso. Lo sto leggendo in questo momento .. – Matt