Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Please add `return false` or `event.preventDefault()` to your keyboard handlers!

Otherwise the browser assumes the page didn't do anything with the events and uses its default keyboard handlers. I have find-as-you-type enabled, and pressing keys launches search for me. Handlers need to "eat" the keyboard events to prevent default browser behavior.



Also: I had Russian keyboard layout when I opened the link, and nothing at all worked. Switching to English fixed it. You should be using key codes, not characters, unless you're accepting text input. Key codes correspond to physical keys on the keyboard, but characters they type don't necessarily.

edit: oh it's on github, gonna submit an issue


Yes! I use colemak, so its rather annoying when there's games that assume WASD but use characters and don't let me rebind the keys.


Also HN, please add "`" for inline monospace text.


what? why?

backtick code comments/snippets from source text are. really not widely standardized, I don't think it makes sense to encourage them without an accompanying web standard, or at least some kind of standard


I'd say that CommonMark is a pretty widely-utilized standard defining formatting including `inline code` snippets.


Gotcha, didn't realize it was standardized. I feel like I heard about CommonMark when it first was announced and I more or less wrote it off as another markup format, but thanks for the clarification.

My poor little internet points <\3 sorry HN for the unforgivable offense of asking a benign question


CommonMark is some kind of standard, and HN’s current syntax is a subset of it.


HN isn’t a web standard.


The markup that it uses for comments should use one though - and apparently it does! Others have mentioned that it uses a subset of CommonMark as mentioned in your post's sibling comments.

Thanks


The page with HN's formatting options is a bit hidden (in the FAQ). I'm not surprised people don't know about it. https://news.ycombinator.com/formatdoc





Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: