Can someone explain why this test fails?


#1

I’m using keycode 72 for demonstration purposes. In my app I’m trying to trigger an enter with keycode 13.

Thanks!


#2

I believe that you can’t programmatically trigger keyboard events like that, for security reasons. The event is received, but no text is entered into the field.

If you are just wanting to trigger an event, though, it works. When I added this line to your JSBin, the console output happened:

find('input').keypress(function() { console.log("hey!"); });

#3

Thanks, maybe you can help me get the test to do what I actually want though. So I have an input set up that on enter fires an action. How would I go about firing an ‘enter’? I was trying keyEvent('input', 'keyup', 13); but that didn’t work.


#4

I modified the JS Bin, the test is able to trigger an enter event on the input. Is that what you need?


#5

Yes, that works! For some reason I only tried keydown and keypress, but I guess I needed to be using keydown. Thank you so much - I thought I was going crazy!