当前位置:网站首页>Resolution: div failed to get keyboard event
Resolution: div failed to get keyboard event
2022-06-30 07:05:00 【Learning makes me happy -- Yuxiang】
Today to div When adding key monitoring, I found that , I can't get the monitoring event
Looking up the data, I found , original html Elements are also categorized by focus , Because the keyboard is different from the mouse :
(1) The mouse can be moved , Select the triggered element
(2) The keyboard doesn't know which element to pass key information to , It is also not possible to move the mouse inside the element every time you type , Then enter the keyboard ........
But because of the concept of focus , Generally, there is at most one focus , Then the keyboard can output according to the focus element .
We can use the element's own tabindex The attribute is div Add permission to have focus .
tabindex="-1" Element has focus permission , The selection will not show , It won't be tab Select... When switching .
tabindex="1" Element has focus permission , The selection will show , Will be tab Toggle selected
tab When switching focus elements , Will be based on tabindex The value size determines the order , The smaller the value. , The higher the priority , The sooner you are chosen , The bigger the value is. , The later it is selected .
After adding the attribute , You'll find that ,div You can receive keyboard events

边栏推荐
猜你喜欢
随机推荐
【Mask-RCNN】基于Mask-RCNN的目标检测和识别
ROS system problem: rosdep init
Linu基础-分区规划与使用
Install go language development tools
【Hot100】11. 盛最多水的容器
【SemiDrive源码分析】【X9芯片启动流程】33 - Display模块 相关概念解析
Problems and solutions of creating topic messages in ROS
js创建pdf文件
Egret P2 physical engine (1) small ball falling demo
已解决:initialize specified but the data directory has files in it. Aborting
vs2019和sql
Qstring to const char*
Google Earth Engine(GEE)——墨累全球潮汐湿地变化 v1 (1999-2019) 数据集
Introduction to go project directory structure
【转】存储器结构、cache、DMA架构分析
解决:div获取不到键盘事件
【最全】linux服务器上安装Mysql
SOC_ SD_ CLK
memcpy内存重叠的解决
oracle数据库报列表中最大表达式为1000错误









