我知道shift key
代码为16
,enter key
代码为13
。
//@ catching any 'enter' keypress in textarea.
function textareaOnEnter(){
$('textarea#someId').keypress(function(e)
{
if(e.which == 13)
{
//.. works only for 'enter'
}
});
}
我认为这可能就像这样简单:
function textareaOnShiftAndEnter(){
$('textarea#someId').keypress(function(e)
{
if(e.which == 13 && e.which == 16)
{
//.. don't work for nothing
}
});
}
但当然它根本无法正常工作。如何查看shift + enter
按键?
答案 0 :(得分:5)
if (e.which == 13 && e.shiftKey)
Shift,Ctrl和Alt是修饰键,它们在事件数据中获得自己的标记。