javascript Key Press

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

Post Reply
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

javascript Key Press

Post by Frame »

is there anyway to detect a key press ? in Javascript.

i´m asking cause i read about, on the wiki

Code: Select all

startUp 
The startUp handler is called after all OXPs have been loaded. It can be used to do one-off initialisation such as registering to listen for certain keystrokes etc. 

But i seem to be unable to find any info on it...
Bounty Scanner
Number 935
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

I take it that there aint any way to detect whether or not the player has pressed a certain key, ingame, inflight.... in a javascript...

i´m not talking about the mission keys...
Bounty Scanner
Number 935
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6625
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

I tried to find some time to have a look at it yesterday (lately spare time has become a short of luxury for me) and was not able to find any indication that Spidermonkey alone can handle key input events. I kept bumping onto references of the JS Event API, which seems to be something different/additional to what we have here and mostly seems to refer to detecting events on browser related scripts.

I think that if something like this were possible, Ahruman would have already made a big bold letter announcement about it. This is the kind of thing that opens new horizons in the game. My best guess at this point is that it is not feasible.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

another_commander wrote:
I tried to find some time to have a look at it yesterday (lately spare time has become a short of luxury for me) and was not able to find any indication that Spidermonkey alone can handle key input events. I kept bumping onto references of the JS Event API, which seems to be something different/additional to what we have here and mostly seems to refer to detecting events on browser related scripts.

I think that if something like this were possible, Ahruman would have already made a big bold letter announcement about it. This is the kind of thing that opens new horizons in the game. My best guess at this point is that it is not feasible.
Thanks for looking, i appreciate it.. :-).

Maybe we should alter the text on the wiki so that other people dont think the same as i did.
Bounty Scanner
Number 935
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

What about this? Perhaps krombart is the man to ask here?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6625
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

Krombart's modification is done directly in the core Obj-C code. Not in JavaScript, unfortunately.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post by Commander McLane »

Okay, then things remain as they are: No additional key-commands.
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Commander McLane wrote:
Okay, then things remain as they are: No additional key-commands.
While i can add some KeyEvents, in a javascript, they seem not to be affected by pressing any keys... as Another_commander, wrote, its meant for GUI or Browsers...

i´m getting "no properties error", which means, while KeyEvent is a reserved word, i cant use it :-/
Bounty Scanner
Number 935
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post by JensAyton »

dajt’s original JavaScript branch had nominal support for keystrokes, which is what the wiki refers to. I don’t think it actually worked properly.

Reintroducing them has been in the back of my mind, but there are problems: what if a user has mapped a game function to your key? What if multiple scripts define the same key? What if the character you select can’t be typed on the user’s keyboard?

The logical fix would be to add scripted keyboard assignments to the keyboard configuration screen. Oh, that’s right, we don’t have one…
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post by Frame »

Ahruman wrote:
dajt’s original JavaScript branch had nominal support for keystrokes, which is what the wiki refers to. I don’t think it actually worked properly.

Reintroducing them has been in the back of my mind, but there are problems: what if a user has mapped a game function to your key? What if multiple scripts define the same key? What if the character you select can’t be typed on the user’s keyboard?

The logical fix would be to add scripted keyboard assignments to the keyboard configuration screen. Oh, that’s right, we don’t have one…

One way is scrool down beetween availeble Equipment that requires a user input and then use a key to activate it, or select it..

Once it has been selected, further options become availeble, if need be...
sort a like when you pick missiles and cargo-to-eject... you call it a computer Interface thingi.

ComputerInterface.plist

Code: Select all


"Fuel_Collector_Option" =
	{
		name = "Fuel Collector";
		script = "Fuel_Collector_selected.js";
	};
}
And

Fuel_Collector_selected.js

Code: Select all


this.startup()
{
  	//just like normal startup
}

this.selected() // this is sort a like shiplaunced from staion
{
// in here you can use all the normal script abilites player.target and so on
}

this.keypressed(theKey)
{
	// depending on what key is pressed
	if(theKey == "a")
	{
		//do something
	}
}
All methods and events that would be make sense should be included...

I know this quite a task offcourse...
Bounty Scanner
Number 935
Post Reply