[OpenLayers-Dev] [Ticket #1108] Code to get around the Non_Firefox keypress issue

Nathan Gerber ngerber999 at gmail.com
Fri Feb 29 09:11:34 EST 2008


As the ticket suggests changing "window" to "document" is a step in this
process, but there is a bit more involved to get it to work. The following
code may not be ideal, but it has gotten around the issue so that my
non-firefox users can successfully delete individual points from a polygon.

Handler/Keyboard.js

    /**
     * Method: handleKeyEvent
     */
    handleKeyEvent: function (evt) {
        if (!evt.charCode) {
            evt.charCode = 0;
        }

        // Non-Firefox Browser Hack for "d" key
        if ((!evt.charCode) && (evt.keyCode == 68)
            && evt.type == 'keydown'
            && navigator.appVersion.match(/Konqueror|Safari|KHTML|MSIE/)) {
            evt.keyCode = 0;
            evt.charCode = 100;
        }

        if (this.checkModifiers(evt)) {
            // Non-Firefox browsers (Internet Explodinator, Safari, Opera)
do not support keypress events
            if (evt.type == 'keydown'
                && navigator.appVersion.match(/Konqueror|Safari|KHTML|MSIE/))
{
                this.callback('keypress', [evt.charCode || evt.keyCode]);
            } else {
                this.callback(evt.type, [evt.charCode || evt.keyCode]);
            }
        }
    },


-- 
--
Nathan Gerber
Web Developer
ZedX, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-dev/attachments/20080229/fa2a899a/attachment.html


More information about the Dev mailing list