views:

118

answers:

1

Hello, I'm struggling to understand why the following problem appears.

I have an input box and I want to attach an Autocomplete box to it.

function input_set_autocomplete_to(obj)
{
    if( obj.type != "text" ) { return; }
    if( obj.getAttribute("rel") != "autocomplete" ) { return; }
    obj.setAttribute("autocomplete", "off");
    obj.setAttribute("uniqindex", Math.round(Math.random()*99999));
    obj.onfocus = function() {
        input_hide_autocompletes();
    };

This is the beginning of the function. No trouble here. Then I hook onkeydown and onkeyup events so I can show the box while the user is typing.

    obj.onkeydown = function(e) {
        console.log('x');
    }
    obj.onkeyup = function (e) {
        console.log('z');
    }

So far so good. Everything works in every single browser (IE, FF, Chrome, Safari) on both Windows and Linux, I get x,z on every keypress, except Opera in Linux if I'm using Cyrillic input (e.g. сдфг). There onkeyup event doesn't even fire.

The system I use is Ubuntu 9.04 with Opera 10.10.

P.S. While typing this question I tried it on another machine with ArchLinux, again with Opera 10.10 and it's working fine. Also a colleague dropped a note that it's not working for him too on MacOS X 10.6 with Safari, but I cannot contact him to identify the version

+1  A: 

According to quirksmode, Opera keyup handling is broken. You need to use keypress on Opera instead.

ssg