我可以确定之前按过哪个键吗?
$("#divex").keypress(getKey);
function getKey(e)
{
//alert previous key pressed to e ???
alert(e.which); //gets current key ascii code
}
答案 0 :(得分:8)
您可以将其存储在变量中:
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
}