faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

32 of 52 people (62%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

how to get the ascii value of del key using javascript events?

Apr 8th, 2008 18:30
ha mo, Dave Clark, smile venkii,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Smile,
     The onkeydown event exposes the Delete key value as 46.
function chkKey(e) {
  var mykey, alt, ctrl, shift;
  if (window.Event) {
    mykey = e.which;
    alt = (e.modifiers & Event.ALT_MASK) ? true : false;
    ctrl = (e.modifiers & Event.CONTROL_MASK) ? true : false;
    shift = (e.modifiers & Event.SHIFT_MASK) ? true : false;
  } else {
    mykey = event.keyCode;
    alt = event.altKey;
    ctrl = event.ctrlKey;
    shift = event.shiftKey;
  }
  if (mykey==46)
    alert("Delete key pressed.');
  return true;
}
document.onkeydown = chkKey;
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com