How do you tell if caps lock is on using JavaScript?(您如何判断大写锁定是否在使用JavaScript?)
One caveat though: I did google it and the best solution I could find was to attach an onkeypress
event to every input, then check each time if the letter pressed was uppercase, and if it was, then check if shift was also held down.(需要注意的是:我用google搜索了,找到的最佳解决方案是将onkeypress
事件附加到每个输入,然后每次检查所按字母是否为大写,如果是大写,则检查是否还按住shift键。)
If it wasn't, therefore caps lock must be on.(如果不是,则必须打开大写锁定。) This feels really dirty and just... wasteful - surely there's a better way than this?(这感觉真的很脏,只是...很浪费 -当然有比这更好的方法了吗?)
ask by nickf translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…