我有一个包含项目的列表。
当我点击这些项目中的任何一个时,我将复制将其id
-值转换成text
-field的形式。
每次我点击它,它会取代该值,默认情况下这是正确的。但是我想补充一点,用户可以在键盘上按住一个按键,然后点击它们,只需点击.append
即可,无论他们只是点击了哪一个表单字段。单击以替换值,shift +单击以使用jquery附加值
这里是我的jQuery的代码,我使用的第一/默认方案:
$(function(){
$('ul#filter-results li').click(function(){
var from = $(this).attr('id'); // get the list ID and
$('input#search').val(from+' ').keyup(); // insert into text-field then trigger the search and
$('input#search').focus(); // make sure the field is focused so the user can start typing immediately
});
});
是否有实现某种形式的键盘键侦听的方式吗?
喜欢的东西:
if (e.shiftKey){
.append('this text instead')
}
还没有尝试过,看看是否shiftKey
是即使在这里