Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
JS keyboard keydown event to unicode

I'm trying to capture user input (for custom non-html input field) so I need unicode hex key of input character

Others answers suggest something like this:

function detectkey(event) {
    var unicode = event.which || event.keyCode;
    document.getElementById("keystroke").innerHTML = "The pressed key was: " + String.fromCharCode(unicode) +"<br>The Unicode value is:"+ unicode;
}

But both event.which and event.keyCode and also charCode are deprecated Proofs:

  • https://developer.mozilla.org/en-US/docs/Web/API/UIEvent/which
  • https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/keyCode
  • https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/charCode

As you can see here https://keycode.info/ There are 2 ways left - event.key and event.code

  • But event.key gives you 'shift', 'control' and other stuff
  • And event.code is a joke
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Damn seems like I need to use keypress event instead. It don't gives you control presses

UPD: Damn*2, it's also deprecated

https://developer.mozilla.org/en-US/docs/Web/API/Document/keypress_event

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!