我可以确定以前按下过哪个键吗?
$("#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
}