admin管理员组文章数量:1356784
I've got this little jquery plugin. There are some images in a vertically scrollable div. I can click on this div and scroll it by using arrow keys.
If you take a look at this example, you can see that I want observe if arrow key right/left is pressed and if so, jump to the next image. In Firefox and IE, the keyup() event is being called, and in safari and chrome it's not.
I have encountered several strange scrolling and focus behaviours in webkit browsers, but I don't know why the keyup() event is not being fired. If you have any idea, please let me know.
I've got this little jquery plugin. There are some images in a vertically scrollable div. I can click on this div and scroll it by using arrow keys.
If you take a look at this example, you can see that I want observe if arrow key right/left is pressed and if so, jump to the next image. In Firefox and IE, the keyup() event is being called, and in safari and chrome it's not.
I have encountered several strange scrolling and focus behaviours in webkit browsers, but I don't know why the keyup() event is not being fired. If you have any idea, please let me know.
Share Improve this question asked Jan 25, 2011 at 8:42 kokokoko 95812 silver badges26 bronze badges1 Answer
Reset to default 11Just add the tabindex
attribute to your div
-element and it will work. This is kind of a hack to make an otherwise not focusable element focusable, just like any input
or button
.
Depending on the value given to tabindex
, it will behave diffrently:
0
will allow you to focus the element with the keyboard arrows and tab key-1
will disable tabbing, but it will still be focusable- Anything greater then
0
will allow you prioratize tab focusing, where1
has the highest priority
I've updated the jsFiddle demo accordingly.
本文标签:
版权声明:本文标题:javascript - keyboard scrolling on focused div in webkit - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743959106a2568687.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论