Skip to content

Commit

Permalink
popup Alt+Enter 清空并聚焦$input
Browse files Browse the repository at this point in the history
  • Loading branch information
WayneXuan committed Jan 11, 2016
1 parent 9bf6def commit 8c4982f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/javascript/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,16 +395,21 @@ toggleKey.onchange = function (event) {
// updateSetting("duration", event.target.value);
// })

//在popup页内 Enter键 查询选中部分 如果没有选中部分,$input请求焦点
/**
* popup页 快捷键绑定
*/
document.addEventListener('keyup',function(e){
if(document.activeElement.tagName=="BODY" && e.which==13){
if(document.activeElement.tagName=="BODY" && e.which==13){ //Enter 查询选中部分 如果没有选中部分,$input请求焦点
var selection=window.getSelection().toString();
if(selection.length>0) {
$historyList.innerHTML = "";
queryInPopup(selection);
}else{
$input.focus();
}
}else if(e.which==18){ //Alt+Enter $input清空内容并请求焦点
$input.value = '';
$input.focus();
}
});

Expand Down

0 comments on commit 8c4982f

Please sign in to comment.