简体   繁体   English

AngularJs捕获“ tab”键

[英]AngularJs capture “tab” key press

I work on angularJs v1 with ngWig plugin. 我使用ngWig插件开发angularJs v1。

I make a lot of questionary, each one having multiples in the same page. 我提出很多问题,每个问题在同一页面中都有多个。

I want to press "tab" key to jump from the content of a to the next one. 我想按“ Tab”键从a的内容跳到下一个。 Actually i have to click with the mouse inside the textarea because pressing tab key jump through each button of the component ( i have 9 on my app ) . 实际上,我必须在文本区域内用鼠标单击,因为按Tab键可跳过组件的每个按钮(我的应用程序中有9个按钮)。 Taking the following example, to write "question 1", "question 2","question 3" and so on. 以下面的示例为例,编写“问题1”,“问题2”,“问题3”等。

在此处输入图片说明

https://plnkr.co/edit/dInpEicp5I5p5D1Cnf5w?p=preview https://plnkr.co/edit/dInpEicp5I5p5D1Cnf5w?p=preview

<body>
  <ng-wig ng-model="text1" class="ngwig-sm"></ng-wig>
  <ng-wig ng-model="text2" class="ngwig-sm"></ng-wig>
  <ng-wig ng-model="text3" class="ngwig-sm"></ng-wig>
  <ng-wig ng-model="text4" class="ngwig-sm"></ng-wig>
  <ng-wig ng-model="text5" class="ngwig-sm"></ng-wig>
</body>

Any idea how to jump from textarea to textarea ? 知道如何从textarea跳到textarea吗?

I would not recommend removing tab focus from buttons as they are intended to be focusable. 我不建议从按钮中删除选项卡焦点,因为它们旨在成为焦点。 But if you are sure about removing tab focus from buttons, here's an approach you can take. 但是,如果您确定要删除按钮上的标签焦点,则可以采用以下方法。

Assumption: You've Jquery as a dependency. 假设:您已经将Jquery作为依赖项。

var ngWigButtons = $('ng-wig .nw-button');   // query buttons inside ngWig
for (var i=0, len=ngWigButtons.length; i<len; i++) {
    ngWigButtons.eq(i).attr('tabindex', -1); // remove tab focus
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM