View Single Post
Old 09-16-2010, 05:44 AM   #83
kartu
PRS+ author
kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.kartu ought to be getting tired of karma fortunes by now.
 
Posts: 1,637
Karma: 2446233
Join Date: Dec 2007
Device: Sony PRS-300, 505, 600, 650, 950
Mark Nord
On 300 it's easy as 2.0.x has new key bindings code and it is NOT run in a "sandbox" context.
On 505 1.1.3 there are at least 2 ways:

1) modify applicationStart.xml, you are after this part:
Code:
			<boolean key="0x27" do="doCenter"/>
			<boolean key="0x27-hold" do="doCenter"/>
			<boolean key="kLeft" do="doLeft"/>
			<boolean key="kRight" do="doRight"/>
			<boolean key="kUp" do="doUp"/>
			<boolean key="kDown" do="doDown"/>
I think adding
Code:
			<boolean key="kUp-hold" do="doUpHold"/>
to the mentioned file and then:
Code:
kbook.model.doUpHold = function () {
// log something
}
should work. The disadvantage is, that if you set it to something other than -hold the function won't be called.

2) You should be able to catch all events by overriding Fskin.device.handleEvent, say like this:

Code:
var oldHandleEvent = Fskin.device.handleEvent;
Fskin.device.handleEvent = function (target, event) {
	try {
		var key = event.getKey();
		// log the key
	} catch (e) {
		// log error
	}
	oldHandleEvent.apply(this, arguments);
};

but it won't work in sandbox context, you have to do it via "compile ". So the easiest way is probably to put this code into a separate file, then load it (I think there is even Core.io.getFileContent) and feed it to compile. Then call the function.
kartu is offline