A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: keyboardEvent issue: Event doesn't function unless you click on Stage

  1. #21
    Senior Member
    Join Date
    Nov 2001
    Posts
    1,145
    I think that if you call a javascript function that focuses your swf from the swf, it will work - don't try to focus until you know the swf is loaded. swfObject is a bit slow to load on mozilla.

  2. #22
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    I used that approach in the demo. On initialization, the swf calls a javascript function which sets up the event listeners in the html document. I wasn't able to find a cross browser solution for actually setting the focus to the swf. In IE, calling focus() on that object element should work, but that doesn't work in other browsers. Passing on the keyboard events is the next best solution.

    jQuery should abstract all the cross-browser javascript issues away. But I didn't have access to enough browsers to fully test it.

    Without some cross-browser solution like jQuery, the event key properties will vary according to browser. Some use keyCode, some charCode, and some a property called 'which'. As well, the process for adding the event listeners to catch the event in the first place will probably differ.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center