Page 1 of 1
javascript Key Press
Posted: Sat Jun 07, 2008 8:53 am
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...
Posted: Sat Jun 07, 2008 9:32 pm
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...
Posted: Sun Jun 08, 2008 9:18 am
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.
Posted: Sun Jun 08, 2008 2:02 pm
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.
Posted: Mon Jun 09, 2008 8:41 am
by Commander McLane
What about
this? Perhaps krombart is the man to ask here?
Posted: Mon Jun 09, 2008 10:19 am
by another_commander
Krombart's modification is done directly in the core Obj-C code. Not in JavaScript, unfortunately.
Posted: Mon Jun 09, 2008 10:35 am
by Commander McLane
Okay, then things remain as they are: No additional key-commands.
Posted: Mon Jun 09, 2008 5:27 pm
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 :-/
Posted: Mon Jul 07, 2008 6:19 pm
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…
Posted: Mon Jul 14, 2008 2:08 pm
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...