def key_callback(type, key)
      key = key.downcase

      # All key events
      @events[:key].each do |id, e|
        e.call(KeyEvent.new(type, key))
      end

      case type
      # When key is pressed, fired once
      when :down
        @events[:key_down].each do |id, e|
          e.call(KeyEvent.new(type, key))
        end
      # When key is being held down, fired every frame
      when :held
        @events[:key_held].each do |id, e|
          e.call(KeyEvent.new(type, key))
        end
      # When key released, fired once
      when :up
        @events[:key_up].each do |id, e|
          e.call(KeyEvent.new(type, key))
        end
      end
    end
def key_callback(type, key)
      key = key.downcase

      # All key events
      @events[:key].each do |id, e|
        e.call(KeyEvent.new(type, key))
      end

      case type
      # When key is pressed, fired once
      when :down
        @events[:key_down].each do |id, e|
          e.call(KeyEvent.new(type, key))
        end
      # When key is being held down, fired every frame
      when :held
        @events[:key_held].each do |id, e|
          e.call(KeyEvent.new(type, key))
        end
      # When key released, fired once
      when :up
        @events[:key_up].each do |id, e|
          e.call(KeyEvent.new(type, key))
        end
      end
    end
Key callback method, called by the native and web extentions