def char_to_virtual_keycode(char)

      unless char.size == 1
        raise "virtual keycode conversion is for single characters only"
      end

      code = char.unpack('U')[0]

      case char
        when '0'..'9'
          [code - ?0.ord + 0x30]
        when 'A'..'Z'
          [VK_SHIFT, code]
        when 'a'..'z'
          [code - ?a.ord + ?A.ord]
        when ' '
          [code]
        when '+'
          [VK_ADD]
        when '='
          [VK_OEM_PLUS]
        when ','
          [VK_OEM_COMMA]
        when '.'
          [VK_OEM_PERIOD]
        when '-'
          [VK_OEM_MINUS]
        when '_'
          [VK_SHIFT, VK_OEM_MINUS]

        when ';'
          [VK_OEM_1]
        when ':'
          [VK_SHIFT, VK_OEM_1]
        when '/'
          [VK_OEM_2]
        when '?'
          [VK_SHIFT, VK_OEM_2]
        when '`'
          [VK_OEM_3]
        when '~'
          [VK_SHIFT, VK_OEM_3]
        when '['
          [VK_OEM_4]
        when '{'
          [VK_SHIFT, VK_OEM_4]
        when '\\'
          [VK_OEM_5]
        when '|'
          [VK_SHIFT, VK_OEM_5]
        when ']'
          [VK_OEM_6]
        when '}'
          [VK_SHIFT, VK_OEM_6]
        when "'"
          [VK_OEM_7]
        when '"'
          [VK_SHIFT, VK_OEM_7]
        when '!'
          [VK_SHIFT, VK_1]
        when '@'
          [VK_SHIFT, VK_2]
        when '#'
          [VK_SHIFT, VK_3]
        when '$'
          [VK_SHIFT, VK_4]
        when '%'
          [VK_SHIFT, VK_5]
        when '^'
          [VK_SHIFT, VK_6]
        when '&'
          [VK_SHIFT, VK_7]
        when '*'
          [VK_SHIFT, VK_8]
        when '('
          [VK_SHIFT, VK_9]
        when ')'
          [VK_SHIFT, VK_0]

        when "\n"
          [VK_RETURN]
        else
          raise "No conversion exists for character #{char}"
      end
    end
def char_to_virtual_keycode(char)

      unless char.size == 1
        raise "virtual keycode conversion is for single characters only"
      end

      code = char.unpack('U')[0]

      case char
        when '0'..'9'
          [code - ?0.ord + 0x30]
        when 'A'..'Z'
          [VK_SHIFT, code]
        when 'a'..'z'
          [code - ?a.ord + ?A.ord]
        when ' '
          [code]
        when '+'
          [VK_ADD]
        when '='
          [VK_OEM_PLUS]
        when ','
          [VK_OEM_COMMA]
        when '.'
          [VK_OEM_PERIOD]
        when '-'
          [VK_OEM_MINUS]
        when '_'
          [VK_SHIFT, VK_OEM_MINUS]

        when ';'
          [VK_OEM_1]
        when ':'
          [VK_SHIFT, VK_OEM_1]
        when '/'
          [VK_OEM_2]
        when '?'
          [VK_SHIFT, VK_OEM_2]
        when '`'
          [VK_OEM_3]
        when '~'
          [VK_SHIFT, VK_OEM_3]
        when '['
          [VK_OEM_4]
        when '{'
          [VK_SHIFT, VK_OEM_4]
        when '\\'
          [VK_OEM_5]
        when '|'
          [VK_SHIFT, VK_OEM_5]
        when ']'
          [VK_OEM_6]
        when '}'
          [VK_SHIFT, VK_OEM_6]
        when "'"
          [VK_OEM_7]
        when '"'
          [VK_SHIFT, VK_OEM_7]
        when '!'
          [VK_SHIFT, VK_1]
        when '@'
          [VK_SHIFT, VK_2]
        when '#'
          [VK_SHIFT, VK_3]
        when '$'
          [VK_SHIFT, VK_4]
        when '%'
          [VK_SHIFT, VK_5]
        when '^'
          [VK_SHIFT, VK_6]
        when '&'
          [VK_SHIFT, VK_7]
        when '*'
          [VK_SHIFT, VK_8]
        when '('
          [VK_SHIFT, VK_9]
        when ')'
          [VK_SHIFT, VK_0]

        when "\n"
          [VK_RETURN]
        else
          raise "No conversion exists for character #{char}"
      end
    end
convert a single character to a virtual keycode

 @param [Char] char is the character to convert

 @return [Array] of virtual keycodes