public void keyTyped(object sender, RsKeyEventArgs e)
        {
            idleTime = 0;
            int i = (int)e.KeyChar;

            if (e.KeyChar >= 32 && e.KeyChar <= 126)
            {
                inputBuffer[writeIndex] = i;
                writeIndex = writeIndex + 1 & 0x7f;
            }
        }
        public void keyPressed(object sender, RsKeyEventArgs e)
        {
            idleTime = 0;
            int i = (int)e.RsKeyCode;

            if (i > 0 && i < 128)
            {
                keyStatus[i] = 1;
            }
            if (i > 4)
            {
                inputBuffer[writeIndex] = i;
                writeIndex = writeIndex + 1 & 0x7f;
            }
        }
        public void keyReleased(object sender, RsKeyEventArgs e)
        {
            idleTime = 0;
            int keyCode = e.RsKeyCode;
            int keyChar = e.RsKeyCode;

            if (keyCode < 30)
            {
                keyChar = 0;
            }
            else if (keyCode == 37)            // Left
            {
                keyChar = 1;
            }
            else if (keyCode == 39)            // Right
            {
                keyChar = 2;
            }
            else if (keyCode == 38)            // Up
            {
                keyChar = 3;
            }
            else if (keyCode == 40)            // Down
            {
                keyChar = 4;
            }
            else if (keyCode == 17)            // CTRL
            {
                keyChar = 5;
            }
            else if (keyCode == 8)            // Backspace
            {
                keyChar = 8;
            }
            else if (keyCode == 127)            // Delete
            {
                keyChar = 8;
            }
            else if (keyCode == 9)            // Meant to be tab but doesn't work
            {
                keyChar = 9;
            }
            else if (keyCode == 10)            // Enter / return
            {
                keyChar = 10;
            }
            else if (keyCode >= 112 && keyCode <= 123)            // F keys
            {
                keyChar = (1008 + keyCode) - 112;
            }
            else if (keyCode == 36)            // Home
            {
                keyChar = 1000;
            }
            else if (keyCode == 35)            // End
            {
                keyChar = 1001;
            }
            else if (keyCode == 33)            // Page up
            {
                keyChar = 1002;
            }
            else if (keyCode == 34)            // Page down
            {
                keyChar = 1003;
            }
            else if (keyChar > 0 && keyChar < 128)
            {
                keyStatus[keyChar] = 1;
            }

            if (keyChar > 0 && keyChar < (char)200)
            {
                this.keyStatus[keyChar] = 0;
            }
        }