code: function getCoords(ev) {
            var x, y, w, h, el;
  
            // ignore browsers without pageX for now
            if (ev.pageX === null) return;
  
            x = ev.pageX;
            y = ev.pageY;
            el = self.element;
  
            // should probably check offsetParent
            // but this is more portable
            while (el !== document.documentElement) {
                x -= el.offsetLeft;
                y -= el.offsetTop;
                el = el.parentNode;
            }
  
            // convert to cols/rows
            w = self.element.clientWidth;
            h = self.element.clientHeight;
            x = ((x / w) * self.cols) | 0;
            y = ((y / h) * self.rows) | 0;
  
            // be sure to avoid sending
            // bad positions to the program
            if (x < 0) x = 0;
            if (x > self.cols) x = self.cols;
            if (y < 0) y = 0;
            if (y > self.rows) y = self.rows;
  
            // xterm sends raw bytes and
            // starts at 32 (SP) for each.
            x += 32;
            y += 32;
  
            return {
                x: x,
                y: y,
                down: ev.type === 'mousedown',
                up: ev.type === 'mouseup',
                wheel: ev.type === wheelEvent,
                move: ev.type === 'mousemove'
            };
        }
docs: mouse coordinates measured in cols/rows