TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Whatthekeycode.com - quickly find a js keycode for any key

141 点作者 timparker将近 13 年前

14 条评论

jayferd将近 13 年前
Key codes are pretty good for little things, but they break down pretty quickly if you want international support. In Mathquill, we ended up just using a hidden textarea and a setTimeout, with a few hilarious hacks. The comments and commit history are worth a read: <a href="https://github.com/mathquill/mathquill/blob/dev/src/textarea.js" rel="nofollow">https://github.com/mathquill/mathquill/blob/dev/src/textarea...</a>
评论 #4478924 未加载
gokhan将近 13 年前
Nice, but fails for me with non-English characters on my keyboard, ğüşöçĞÜŞÖÇ, and can't differentiate i and ı.
评论 #4478827 未加载
评论 #4478666 未加载
deepakg将近 13 年前
Probably relevant to the discussion, the mousetrap library: <a href="http://craig.is/killing/mice" rel="nofollow">http://craig.is/killing/mice</a>
评论 #4479060 未加载
评论 #4479054 未加载
gibybo将近 13 年前
Heh, I've lost count of how many times I've written "document.onkeydown = function(e) { console.log(e.keyCode); }" to deal with this. This is probably easier, if I can remember it when I need it :)
anvandare将近 13 年前
DOM keycodes are kind of broken beyond repair[1]. They cannot be relied upon to determine precisely which character a user entered (even jQuery's charcode falls short here) because they do not take into account modifier keys, compositions, or locales.<p>[1] For a (detailed) explanation: <a href="http://unixpapa.com/js/key.html" rel="nofollow">http://unixpapa.com/js/key.html</a>
NVI将近 13 年前
I made something like this a while ago <a href="http://elv1s.ru/files/js/key-code-detector.html" rel="nofollow">http://elv1s.ru/files/js/key-code-detector.html</a>
kunil将近 13 年前
On an unrelated note, is there way to forbid sites to override ctrl+w? I hate it when a web page is not closed with a short cut.<p>edit: I am using firefox
评论 #4479535 未加载
评论 #4478832 未加载
goochtek将近 13 年前
It's kind of ironic that you can't bookmark it in Chrome using the ctrl+d shortcut when this is one of those perfect bookmark tools.
评论 #4478707 未加载
klibertp将近 13 年前
This: <a href="http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes" rel="nofollow">http://www.cambiaresearch.com/articles/15/javascript-char-co...</a> was sitting in my bookmarks for quite some time now... And will be there, because I use vrome which seems to capture the key presses when there's no input focused :(
TomGullen将近 13 年前
Nice! But shift-key doesn't work. For example if I want to get the code for +
评论 #4479032 未加载
DigitalSea将近 13 年前
Anyone ever noticed that the print screen key is from what I can see, the only key on a conventional qwerty keyboard that doesn't have an event code? What's the reasoning for that?
ernestipark将近 13 年前
The key that is being pressed should be shown on the page somewhere - though it would make it look uglier. But for a utility like this, probably won't matter all that much.
评论 #4479536 未加载
joefarish将近 13 年前
Doesn't work in IE8. I know IE8 isn't exactly the latest and greatest web browser but some of us are stuck using it at work!
评论 #4479367 未加载
princeverma将近 13 年前
it would be nice if it can simultaneously display appropriate JS code to bind for a particular key. Also, if it can recognize key combos like ctrl-alt-s
评论 #4479268 未加载
评论 #4479033 未加载