I have two functions.(我有两个功能。)
When enter is pressed the functions runs correctly but when escape is pressed it doesn't.(当按下enter时,功能正常运行,但是当按下escape时它不会。) What's the correct number for the escape key?(转义键的正确数字是多少?)
$(document).keypress(function(e) {
if (e.which == 13) $('.save').click(); // enter (works as expected)
if (e.which == 27) $('.cancel').click(); // esc (does not work)
});
ask by Shishant translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…