Sets key bindings -- we need this more than once
172729
def set_bind(self):
        
        IntegerEntry.set_bind(self)
        self.unbind('<Shift-Up>')
        self.unbind('<Shift-Down>')
        self.unbind('<Control-Up>')
        self.unbind('<Control-Down>')
        self.unbind('<Double-Button-1>')
        self.unbind('<Double-Button-3>')
        self.unbind('<Shift-Button-1>')
        self.unbind('<Shift-Button-3>')
        self.unbind('<Control-Button-1>')
        self.unbind('<Control-Button-3>')

        self.bind('<Button-1>', lambda e: self.add(1))
        self.bind('<Button-3>', lambda e: self.sub(1))
        self.bind('<Up>', lambda e: self.add(1))
        self.bind('<Down>', lambda e: self.sub(1))
        self.bind('<Enter>', self._enter)
        self.bind('<Next>', lambda e: self.set(self.allowed[0]))
        self.bind('<Prior>', lambda e: self.set(self.allowed[-1]))
147468
def on_key_up(self):
        
        if (self.last_pressed is not None):
            self.set_key_state(self.last_pressed, 0)
            self.buffer = self.last_pressed.update_buffer(self.buffer)
            self.text_consumer(self.buffer)
            self.last_pressed = None
1006374
def on_key_release_repeat(self, *dummy):
        
        self.has_prev_key_release = self.after_idle(self.on_key_release, dummy)
1058058
private void shortcutChanged(String shortcut, boolean unbind) {
        Set<String> bindings = new HashSet<>();
        bindings.add(shortcut);
        
        for (BaseUIComponent component : componentBindings) {
            CommandUtil.updateShortcuts(component, bindings, unbind);
        }
    }
1294180
def _bind_key(self, key, func):
        """
        if not callable(func):
            print u"Trying to bind non method to keystroke:%s,%s"%(key,func)
            raise ReadlineError(u"Trying to bind non method to keystroke:%s,%s,%s,%s"%(key,func,type(func),type(self._bind_key)))
        keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()
        log(u">>>%s -> %s<<<"%(keyinfo,func.__name__))
        self.key_dispatch[keyinfo] = func
470489
def setKey(self, key):
		""""""
		self.key_size = 24  # Use DES-EDE3 mode
		if len(key) != self.key_size:
			if len(key) == 16: # Use DES-EDE2 mode
				self.key_size = 16
			else:
				raise ValueError("Invalid triple DES key size. Key must be either 16 or 24 bytes long")
		if self.getMode() == CBC:
			if not self.getIV():
				# Use the first 8 bytes of the key
				self._iv = key[:self.block_size]
			if len(self.getIV()) != self.block_size:
				raise ValueError("Invalid IV, must be 8 bytes in length")
		self.__key1 = des(key[:8], self._mode, self._iv,
				  self._padding, self._padmode)
		self.__key2 = des(key[8:16], self._mode, self._iv,
				  self._padding, self._padmode)
		if self.key_size == 16:
			self.__key3 = self.__key1
		else:
			self.__key3 = des(key[16:], self._mode, self._iv,
					  self._padding, self._padmode)
		_baseDes.setKey(self, key)
482604
def load_key_bindings_for_prompt(**kw):
    
    kw.setdefault('enable_abort_and_exit_bindings', True)
    kw.setdefault('enable_search', True)
    kw.setdefault('enable_auto_suggest_bindings', True)

    return load_key_bindings(**kw)
1352002
function(e) {
		var n = e.keyCode,
			c = this._keymap[n],
			b = gui.BROADCAST_KEYEVENT;
		var id = e.currentTarget.defaultView.gui.$contextid;

		/*
		// TODO: THIS!
		if ( e.ctrlKey && gui.Key.$key [ e.keyCode ] !== "Control" ) {
			e.preventDefault ();
		}
		*/

		switch (e.type) {
			case "keydown":
				if (c === undefined) {
					this._keycode = n;
					this._keymap[n] = null;
					this._keymap[n] = String.fromCharCode(e.which).toLowerCase();
					gui.Tick.next(function() {
						c = this._keymap[n];
						this._broadcast(true, null, c, n, id);
						this._keycode = null;
					}, this);
				}
				break;
			case "keypress":
				if (this._keycode) {
					c = this._keychar(e.keyCode, e.charCode, e.which);
					this._keymap[this._keycode] = c;
				}
				break;
			case "keyup":
				if (c !== undefined) {
					this._broadcast(false, null, c, n, id);
					delete this._keymap[n];
				}
				break;
		}
	}
1265501
def OnKey(self, event):
        """"""

        def switch_to_next_table():
            newtable = self.grid.current_table + 1
            post_command_event(self.grid, self.GridActionTableSwitchMsg,
                               newtable=newtable)

        def switch_to_previous_table():
            newtable = self.grid.current_table - 1
            post_command_event(self.grid, self.GridActionTableSwitchMsg,
                               newtable=newtable)

        grid = self.grid
        actions = grid.actions

        shift, alt, ctrl = 1, 1 << 1, 1 << 2

        # Shortcuts key tuple: (modifier, keycode)
        # Modifier may be e. g. shift | ctrl

        shortcuts = {
            # <Esc> pressed
            (0, 27): lambda: setattr(actions, "need_abort", True),
            # <Del> pressed
            (0, 127): actions.delete,
            # <Home> pressed
            (0, 313): lambda: actions.set_cursor((grid.GetGridCursorRow(), 0)),
            # <Ctrl> + R pressed
            (ctrl, 82): actions.copy_selection_access_string,
            # <Ctrl> + + pressed
            (ctrl, 388): actions.zoom_in,
            # <Ctrl> + - pressed
            (ctrl, 390): actions.zoom_out,
            # <Shift> + <Space> pressed
            (shift, 32): lambda: grid.SelectRow(grid.GetGridCursorRow()),
            # <Ctrl> + <Space> pressed
            (ctrl, 32): lambda: grid.SelectCol(grid.GetGridCursorCol()),
            # <Shift> + <Ctrl> + <Space> pressed
            (shift | ctrl, 32): grid.SelectAll,
        }

        if self.main_window.IsFullScreen():
            # <Arrow up> pressed
            shortcuts[(0, 315)] = switch_to_previous_table
            # <Arrow down> pressed
            shortcuts[(0, 317)] = switch_to_next_table
            # <Space> pressed
            shortcuts[(0, 32)] = switch_to_next_table

        keycode = event.GetKeyCode()

        modifier = shift * event.ShiftDown() | \
            alt * event.AltDown() | ctrl * event.ControlDown()

        if (modifier, keycode) in shortcuts:
            shortcuts[(modifier, keycode)]()

        else:
            event.Skip()
758918
def bind(cls):
        
        super(cls, cls).bind()

        cls.search_btn_el.bind("click", cls.start)
        cls.input_el.bind("keypress", func_on_enter(cls.start))
581735
def set_keys(self, keys):
        
        codes = {}
        for key in keys:
            parts = [k.strip().lower() for k in key.split("+")]
            code = KEYS.get(parts[-1])
            modifier = Qt.KeyboardModifiers()
            if code is None:
                raise KeyError("Invalid key code '{}'".format(key))
            if len(parts) > 1:
                for mod in parts[:-1]:
                    mod_code = MODIFIERS.get(mod)
                    if mod_code is None:
                        raise KeyError("Invalid key modifier '{}'"
                                       .format(mod_code))
                    modifier |= mod_code
            if code not in codes:
                codes[code] = []
            codes[code].append(modifier)
        self.codes = codes
369121
def map_keys
      super
      @keys_mapped = true
      bind_key($row_selector, 'toggle row selection'){ toggle_row_selection() }
      bind_key(KEY_ENTER, 'toggle expanded state') { toggle_expanded_state() }
      bind_key(?o, 'toggle expanded state') { toggle_expanded_state() }
      bind_key(?f, 'first row starting with char'){ set_selection_for_char() }
      #bind_key(?\M-v, 'one key selection toggle'){ @one_key_selection = !@one_key_selection }
      bind_key(?O, 'expand children'){ expand_children() }
      bind_key(?X, 'collapse children'){ collapse_children() }
      bind_key(?>, :scroll_right)
      bind_key(?<, :scroll_left)
      # TODO
      bind_key(?x, 'collapse parent'){ collapse_parent() }
      bind_key(?p, 'goto parent'){ goto_parent() }
      # # commented since textpad is now calling this
      # this can be brought back into include and used from other textpad too.
      #require 'canis/core/include/listbindings'
      #bindings
    end
719880
function _bindKeypress(state) {
    state.onKeypress = function(ch, key) {
        if (!key || !state.onFirstLine) {
            // Ignore the up/down history searcing when we've extended to a new line
            return;
        }

        var replace = null;
        if (_keyIs(key, 'up')) {
            replace = state.history.prev();
        } else if (_keyIs(key, 'down')) {
            replace = state.history.next();
        }

        if (_.isString(replace)) {
            // This will close the current prompt, so we can safely get a new one by re-invoking
            // `_read`
            _resetReadLine(state);
            state.currentLine = replace;
            return _read(state);
        }
    };

    state.input.on('keypress', state.onKeypress);
}
295808
protected void setupKeying() {
		setOnKeyPressed(event -> {
			switch (event.getCode()) {
			case LEFT:
				moveLeft(event.isShiftDown(), event.isControlDown(), false);
				event.consume();
				break;
			case RIGHT:
				moveRight(event.isShiftDown(), event.isControlDown(), false);
				event.consume();
				break;
			case UP:
				if (event.isAltDown()) {
					zoomIn();
				} else {
					moveUp(event.isShiftDown(), event.isControlDown(), false);
				}
				event.consume();
				break;
			case DOWN:
				if (event.isAltDown()) {
					zoomOut();
				} else {
					moveDown(event.isShiftDown(), event.isControlDown(), false);
				}
				event.consume();
				break;
			case PAGE_UP:
				if (event.isControlDown()) {
					moveLeft(false, false, true);
				} else {
					moveUp(false, false, true);
				}
				event.consume();
				break;
			case PAGE_DOWN:
				if (event.isControlDown()) {
					moveRight(false, false, true);
				} else {
					moveDown(false, false, true);
				}
				event.consume();
				break;
				//$CASES-OMITTED$
			default:
			}
		});
	}
1095218
public void setupKeys()
    {   // Override this to set up the actual keys
         KeyAreaInfo keyArea = null;
         keyArea = new KeyAreaInfo(this, Constants.UNIQUE, ID_KEY);
         keyArea.addKeyField(ID, Constants.ASCENDING);
    }
1176814
function () {
            var me = this, shortcutkeys = this.shortcutkeys;
            me.addListener('keydown', function (type, e) {
                var keyCode = e.keyCode || e.which;
                for (var i in shortcutkeys) {
                    var tmp = shortcutkeys[i].split(',');
                    for (var t = 0, ti; ti = tmp[t++];) {
                        ti = ti.split(':');
                        var key = ti[0], param = ti[1];
                        if (/^(ctrl)(\+shift)?\+(\d+)$/.test(key.toLowerCase()) || /^(\d+)$/.test(key)) {
                            if (( (RegExp.$1 == 'ctrl' ? (e.ctrlKey || e.metaKey) : 0)
                                && (RegExp.$2 != "" ? e[RegExp.$2.slice(1) + "Key"] : 1)
                                && keyCode == RegExp.$3
                                ) ||
                                keyCode == RegExp.$1
                                ) {
                                if (me.queryCommandState(i,param) != -1)
                                    me.execCommand(i, param);
                                domUtils.preventDefault(e);
                            }
                        }
                    }

                }
            });
        }
432727
private void setUpExtraKeys(GameSettings settings)
    {
        // Create extra key bindings here and pass them to the KeyManager.
        ArrayList<InternalKey> extraKeys = new ArrayList<InternalKey>();
        // Create a key binding to toggle between player and Malmo control:
        extraKeys.add(new InternalKey("key.toggleMalmo", 28, "key.categories.malmo")	// 28 is the keycode for enter.
        {
            @Override
            public void onPressed()
            {
                InputType it = (inputType != InputType.AI) ? InputType.AI : InputType.HUMAN;
                System.out.println("Toggling control between human and AI - now " + it);
                setInputType(it);
                super.onPressed();
            }
        });

        extraKeys.add(new InternalKey("key.handyTestHook", 22, "key.categories.malmo")
        {
            @Override
            public void onPressed()
            {
                // Use this if you want to test some code with a handy key press
                try
                {
                    CraftingHelper.dumpRecipes("recipe_dump.txt");
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
        });
        this.keyManager = new KeyManager(settings, extraKeys);
    }