Trigger F8 keydown event programatically

Iam wondering is there any way to simulate keyevent of exact key? For example in my app i want to programatically trigget F8 key. Any ideas?

Have you tried the approach described in the MDN documentation?