List Info

Thread: onkeypress on body element




onkeypress on body element
user name
2006-07-05 13:08:18
I have a  script to make hotkeys on my web. I have to
"register" the
onkeypress on the body on a page.
If I make the tipical "<body
onkeypress='myfunction();'>" it works, but
I want to change this for using behaviour.
I don't know if this is posible, because I'm making
------------------------------------------------------------
-----
var myrules = {
'body' : function(element){
	element.onkeypress = function(e){
		alert("hi");
	}
}};
Behaviour.register(myrules);
------------------------------------------------------------
-----
and this is not working!

Please, help!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Behaviour Javascript Library"
group.
To post to this group, send email to behaviourgooglegroups.com
To unsubscribe from this group, send email to
behaviour-unsubscribegooglegroups.com
For more options, visit this group at http://group
s.google.com/group/behaviour
-~----------~----~----~----~------~----~------~--~---

onkeypress on body element
user name
2006-07-05 14:41:43
On 05/07/06, ecentinelagmail.com <ecentinelagmail.com> wrote:
>
> I have a  script to make hotkeys on my web. I have to
"register" the
> onkeypress on the body on a page.
> If I make the tipical "<body
onkeypress='myfunction();'>" it works, but
> I want to change this for using behaviour.
> I don't know if this is posible, because I'm making
>
------------------------------------------------------------
-----
> var myrules = {
> 'body' : function(element){
>         element.onkeypress = function(e){
>                 alert("hi");
>         }
> }};
> Behaviour.register(myrules);
>
------------------------------------------------------------
-----
> and this is not working!

Are you using a Gecko based browser? Your script works fine
on the
other browsers I tried. It seems that Gecko based browsers
stores the
body's onkeypress event in the window object. I believe
this is
non-standard, although I'm not sure.

Anyway, I think the normal way to do this it to use
'document.onkeypress'. Since 'document' is always
available you can do
this outside of Behaviour:

document.onkeypress = function(e) {
    alert("hi");
}

Daniel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Behaviour Javascript Library"
group.
To post to this group, send email to behaviourgooglegroups.com
To unsubscribe from this group, send email to
behaviour-unsubscribegooglegroups.com
For more options, visit this group at http://group
s.google.com/group/behaviour
-~----------~----~----~----~------~----~------~--~---

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )