Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3347090
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:22:50+00:00 2026-05-18T01:22:50+00:00

I am trying to simulate keypresses in a web application, it is for an

  • 0

I am trying to simulate keypresses in a web application, it is for an embedded system but it uses a Webkit derived browser. I have tested the code in Chrome and get the same error.

I tried to use code snippets from this example from Yahoo, but I keep getting the same error when firing the event using dispatchEvent. “target” is an HTML element in the DOM tree.

function fireEvent(target) {
    var evt = document.createEvent("UIEvent");
    evt.initEvent("keypress", true, true);
    target.dispatchEvent(evt);
}

It always throws:

“Error: UNSPECIFIED_EVENT_TYPE_ERR: DOM Events Exception 0”

I have tried createEvent("Events") as well and it always boils down to the same exception, both on the embedded system and in Chrome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T01:22:50+00:00Added an answer on May 18, 2026 at 1:22 am

    Ok, when doing further testing, it seemed that when all key event parameters was properly initialised, then dispatchEvent worked without fireing an exception.

    The following code works.

    function fireEvent(target) {
        var evt = document.createEvent("Events");
        evt.initEvent("keypress", true, true);
    
        evt.view = window;
        evt.altKey = false;
        evt.ctrlKey = false;
        evt.shiftKey = false;
        evt.metaKey = false;
        evt.keyCode = 0;
        evt.charCode = 'a';
    
        target.dispatchEvent(evt);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to simulate some code that I have working with SQL but using
I'm trying to simulate a token ring using python with sockets, but I have
I have a sample code run in kernel(2.6.30 x86_64) mode(r0),trying to simulate a iret.I
I'm trying to simulate a particle system using OpenGl but I can't get it
I am trying to simulate a simple MIPS processor using behavior code in Verilog.
I have a 32GB memory machine and I want to simulate trying out one
I'm trying to simulate the Matrix code rain with the canvas element and javascript.
I am trying to simulate a problem we have with a particular domain ID
I'm trying to simulate behavior of os.system with Popen and waitpid on Ubuntu and
I'm trying to simulate the behavior of a DNS server, which I have a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.