I need to trigger Esc keyup even on an HTML element in my unit tests. I am using the following code:
$(".my-element").trigger({type: "keyup", which: 27})
Everything works. But I am just wondering is there a better way of doing it? What are the alternatives?
I think for unit tests if this works you are good. If you wish to test user inputs (key strokes, mouse input) against your web client maybe consider using Selenium, WebDriver or Windmill Testing Framework. Unit tests are usually reserved for testing code logic.