Skip to content

Commit

Permalink
when enter key is pressed
Browse files Browse the repository at this point in the history
 1. if there is a actived tab,close window
 2. else trigger arrow down key pressed to selected first tab
  • Loading branch information
敖武 committed Sep 9, 2019
1 parent ddd3c1a commit e27ce5f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,15 @@ document.addEventListener("DOMContentLoaded", function() {
makeNextTabActive();
break;
case 13: //enter
window.close();
// open first tab when where is no actived tab
var activeTab = document.querySelector("li.tab.active");
if(!activeTab){
var arrowDownEvent = new Event('keydown');
arrowDownEvent.keyCode = 40;
document.dispatchEvent(arrowDownEvent)
}else{
window.close()
}
break;
case 27: //esc
window.close();
Expand Down

0 comments on commit e27ce5f

Please sign in to comment.