3
我可以確定以前按哪個鍵嗎?我可以確定先前按下了哪個按鍵嗎? JavaScript
$("#divex").keypress(getKey);
function getKey(e)
{
//alert previous key pressed to e ???
alert(e.which); //gets current key ascii code
}
我可以確定以前按哪個鍵嗎?我可以確定先前按下了哪個按鍵嗎? JavaScript
$("#divex").keypress(getKey);
function getKey(e)
{
//alert previous key pressed to e ???
alert(e.which); //gets current key ascii code
}
您可以將其存儲在一個變量:
var prevKey = null;
$("#divex").keypress(getKey);
function getKey(e)
{
if (prevKey !== null) alert(prevKey);
prevKey = e.which;
alert(e.which); //gets current key ascii code
}
是有道理的。我只是認爲會有一些內置的方法來獲得該密鑰。 Thanx –
@mircea。不用謝 :) – Sarfraz