Search code examples
javascriptwebonkeydown

Javascript: Add onkeydown event to prompt()


I was wondering that could it somehow be possible to add onkeydown event to prompt()?


Solution

  • No you can't becouse is a browser native dialog function and it is not available by the DOM.

    You can achieve a similar effect with some external javascript library like jQuery.Dialog or bootstrap modal or simplemodal and then attach to that event