def bind_key keycode, *args, &blk
        #$log.debug " #{@name} bind_key received #{keycode} "
        @_key_map ||= {}
        #
        # added on 2011-12-4 so we can pass a description for a key and print it
        # The first argument may be a string, it will not be removed
        # so existing programs will remain as is.
        @key_label ||= {}
        if args[0].is_a?(String) || args[0].is_a?(Symbol)
          @key_label[keycode] = args[0] 
        else
          @key_label[keycode] = :unknown
        end

        if !block_given?
          blk = args.pop
          raise "If block not passed, last arg should be a method symbol" if !blk.is_a? Symbol
          #$log.debug " #{@name} bind_key received a symbol #{blk} "
        end
        case keycode
        when String
          # single assignment
          keycode = keycode.getbyte(0) 
        when Array
          # double assignment
          # this means that all these keys have to be pressed in succession for this block, like "gg" or "C-x C-c"
          raise "A one key array will not work. Pass without array" if keycode.size == 1
          ee = []
          keycode.each do |e| 
            e = e.getbyte(0) if e.is_a? String
            ee << e
          end
          bind_composite_mapping ee, args, blk
          return self
          #@_key_map[a0] ||= OrderedHash.new
          #@_key_map[a0][a1] = blk
          #$log.debug " XX assigning #{keycode} to  _key_map " if $log.debug? 
        else
          $log.debug " assigning #{keycode} to  _key_map for #{self.class}, #{@name}" if $log.debug? 
        end
        @_key_map[keycode] = blk
        @_key_args ||= {}
        @_key_args[keycode] = args
        self
      end
def bind_key keycode, *args, &blk
        #$log.debug " #{@name} bind_key received #{keycode} "
        @_key_map ||= {}
        #
        # added on 2011-12-4 so we can pass a description for a key and print it
        # The first argument may be a string, it will not be removed
        # so existing programs will remain as is.
        @key_label ||= {}
        if args[0].is_a?(String) || args[0].is_a?(Symbol)
          @key_label[keycode] = args[0] 
        else
          @key_label[keycode] = :unknown
        end

        if !block_given?
          blk = args.pop
          raise "If block not passed, last arg should be a method symbol" if !blk.is_a? Symbol
          #$log.debug " #{@name} bind_key received a symbol #{blk} "
        end
        case keycode
        when String
          # single assignment
          keycode = keycode.getbyte(0) 
        when Array
          # double assignment
          # this means that all these keys have to be pressed in succession for this block, like "gg" or "C-x C-c"
          raise "A one key array will not work. Pass without array" if keycode.size == 1
          ee = []
          keycode.each do |e| 
            e = e.getbyte(0) if e.is_a? String
            ee << e
          end
          bind_composite_mapping ee, args, blk
          return self
          #@_key_map[a0] ||= OrderedHash.new
          #@_key_map[a0][a1] = blk
          #$log.debug " XX assigning #{keycode} to  _key_map " if $log.debug? 
        else
          $log.debug " assigning #{keycode} to  _key_map for #{self.class}, #{@name}" if $log.debug? 
        end
        @_key_map[keycode] = blk
        @_key_args ||= {}
        @_key_args[keycode] = args
        self
      end
--- }}}

 A new attempt at a flat hash 2014-05-06 - 00:16
 bind an action to a key, required if you create a button which has a hotkey
 or a field to be focussed on a key, or any other user defined action based on key
 e.g. bind_key ?\C-x, object, block
 added 2009-01-06 19:13 since widgets need to handle keys properly
  2010-02-24 12:43 trying to take in multiple key bindings, TODO unbind
  TODO add symbol so easy to map from config file or mapping file

  Ideally i want to also allow a regex and array/range to be used as a key
  However, then how do i do multiple assignments which use an array.

  Currently the only difference is that there is no hash inside the value,
  key can be an int, or array of ints (for multiple keycode like qq or gg).