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 926623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:42:50+00:00 2026-05-15T19:42:50+00:00

This is sufficiently important to me that I’m opening the question up to a

  • 0

This is sufficiently important to me that I’m opening the question up to a bounty with a simple goal: Can anyone successfully open a new, full-screen NativeWindow in AJAX Air and, from that window, detect key strokes?

Hopefully I’m just overlooking something really, really simple, but if JS is not capable of listening for keyboard events, maybe a flash widget/helper might be able to relay keyboard events to JS. That’s the only thing I can think of, but there may be other ways. I just don’t know. Hopefully someone out there knows the right answer!


Update

Many thanks to @mwilcox for the answer. I don’t know what the difference is between the method I was using (from the O’Reilly Cookbook) and createRootWindow(), but whatever it is, it did solve my problems. The code I ended up using is this:

var objWindowOptions = new air.NativeWindowInitOptions();
objWindowOptions.transparent = false;
objWindowOptions.systemChrome = air.NativeWindowSystemChrome.STANDARD;
objWindowOptions.type= air.NativeWindowType.NORMAL;

var linkScreenToMainWindow = function() {
    wWindow.removeEventListener(air.Event.COMPLETE,linkScreenToMainWindow);
    objScreen.setWindowReference(wWindow.stage.getChildAt(0).window);
    // At this point your windows are connected and you can fire commands into
    // the window using objScreen as a proxy. For example:
    alert(objScreen.document.body.innerHTML);
    objScreen.myfunction();
};

var fhFilePath = air.File.applicationDirectory.resolvePath('childwindow.html');

wWindow   = air.HTMLLoader.createRootWindow(true, objWindowOptions, true);
wWindow.stage.displayState = window.runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
wWindow.addEventListener(air.Event.COMPLETE,linkScreenToMainWindow);
wWindow.load(new air.URLRequest(fhFilePath.url));

I’ve created a new window in Adobe Air (JS) and I need to capture any key-presses (or keydowns if it’s easier). I have no problem adding an event listener to the main window, but any child window doesn’t seem to recognize any of the common hook techniques.

Part of the problem, I think, is that the first parameter of addEventListener() is the name of the event, and all of the documented event names fail to raise any events. Any idea what how I’m supposed to do this?

Main window

// Keyboard handler and event listener subscription:
var watcher = function() {
    alert("Working");
};
window.addEventListener("keypress",watcher,false); // WORKS!

// Create child window:
var wWindow = new air.NativeWindow(objWindowOptions);
wWindow.activate();

wWindow.stage.displayState = window.runtime.flash.display.StageDisplayState.FULL_SCREEN_INTERACTIVE;
wWindow.stage.scaleMode = "noScale"; 
wWindow.stage.addChild( htmlView ); 
htmlView.load( new air.URLRequest("newpage.html") );

Child window: newpage.html

// Keyboard handler and event listener subscription
var handler = function() {
    alert('success!');
};
var strEventName = KeyboardEvent.KEY_DOWN; // Fails -- is undefined
//var strEventName = KeyboardEvent.KEYDOWN; // Fails -- is undefined
//var strEventName = 'keydown'; // Fails
// var strEventName = 1024; // Fails

window.nativeWindow.stage.addEventListener(strEventName,handler,false); // Fails
nativeApplication.addEventListener(strEventName,handler,false); // Fails
window.addEventListener(strEventName,handler,false); // Fails

I may be mistaken, but I think I’ve tried every permutation of the above and none of them work.

  • 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-15T19:42:51+00:00Added an answer on May 15, 2026 at 7:42 pm

    I think you’re missing a step. Try:

    var newWin = air.HTMLLoader.createRootWindow(...options);
    var container = newWin.window.nativeWindow;
    

    Otherwise, are you sure AIR is loaded in that child window?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have already posted a question about this, but the situation has changed sufficiently
This somehow simple task is not so simple. I can get the number of
This goes back to my other question which I thought was sufficiently answers but
I'm new to iPhone development, so apologies if this is a silly question, but
Is this encryption class sufficiently secure? Or can someone disassemble my binary to find
This should be simple, but the answer is eluding me. If I've got a
this is my code that I write it but I want to use LINQ
This is probably a stupid question, but how much of a security risk is
Is there a good way to do this? I'm writing an extension that interacts
Edit 2: For a practical demonstration of why this remains important, look no further

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.