inspect if keystroke matches
432005
function (event) {
        //event = $.event.fix(event); // jQuery event normalization.
        var element = this;//event.target;
        // @ TextNode -> nodeType == 3
        element = (element.nodeType == 3) ? element.parentNode : element;

        if (opt['disableInInput']) { // Disable shortcut keys in Input, Textarea fields
            var target = element;//$(element);
            if (target.tagName == "INPUT" || target.tagName == "TEXTAREA") {
                return;
            }
        }
        var code = event.which,
            type = event.type,
            character = String.fromCharCode(code).toLowerCase(),
            special = that.special_keys[code],
            shift = event.shiftKey,
            ctrl = event.ctrlKey,
            alt = event.altKey,
            propagate = true, // default behaivour
            mapPoint = null;

        // in opera + safari, the event.target is unpredictable.
        // for example: 'keydown' might be associated with HtmlBodyElement
        // or the element where you last clicked with your mouse.
        if (opt.checkParent) {
//              while (!that.all[element] && element.parentNode){
            while (!element['hotkeys'] && element.parentNode) {
                element = element.parentNode;
            }
        }

//          var cbMap = that.all[element].events[type].callbackMap;
        var cbMap = element['hotkeys'].events[type].callbackMap;
        if (!shift && !ctrl && !alt) { // No Modifiers
            mapPoint = cbMap[special] || cbMap[character];
        }
        // deals with combinaitons (alt|ctrl|shift+anything)
        else {
            var modif = '';
            if (alt) modif += 'alt+';
            if (ctrl) modif += 'ctrl+';
            if (shift) modif += 'shift+';
            // modifiers + special keys or modifiers + characters or modifiers + shift characters
            mapPoint = cbMap[modif + special] || cbMap[modif + character] || cbMap[modif + that.shift_nums[character]];
        }
        if (mapPoint) {
            mapPoint.cb(event);
            if (!mapPoint.propagate) {
                event.stopPropagation();
                event.preventDefault();
                return false;
            }
        }
    }
982914
function fileSearch_kp(e){
    e = e || window.event;

    // If there are any modifiers or if we're already entering text into
    // another input field elsewhere, then do nothing
    if(e.ctrlKey || e.altKey || e.metaKey || e.target.tagName === 'INPUT') return true;

    // Grab the typed character, test it, and show the box if appropriate
    var theChar = String.fromCharCode(e.which);
    if(/[a-zA-Z0-9\.\/\_\-]/.test(theChar)) showSearchBox(theChar);
  }
1157393
def pressed_keys(self):
        """"""
        # make a list of all the keys that are detected
        pressed = []

        # set all pins pins to be inputs w/pullups
        for pin in self.row_pins+self.col_pins:
            pin.direction = Direction.INPUT
            pin.pull = Pull.UP

        for row in range(len(self.row_pins)):
            # set one row low at a time
            self.row_pins[row].direction = Direction.OUTPUT
            self.row_pins[row].value = False
            # check the column pins, which ones are pulled down
            for col in range(len(self.col_pins)):
                if not self.col_pins[col].value:
                    pressed.append(self.keys[row][col])
            # reset the pin to be an input
            self.row_pins[row].direction = Direction.INPUT
            self.row_pins[row].pull = Pull.UP
        return pressed
888665
function checkModifierKeys(oEvent, bCtrlKey, bAltKey, bShiftKey) {
		return oEvent.shiftKey == bShiftKey && oEvent.altKey == bAltKey && getCtrlKey(oEvent) == bCtrlKey;
	}
1080275
def _process_keystroke_movement(self, inp, idx, offset):
        """"""
        term = self.term
        if inp in (u'y', u'k') or inp.code in (term.KEY_UP,):
            # scroll backward 1 line
            idx, offset = (idx, offset - self.screen.num_columns)
        elif inp in (u'e', u'j') or inp.code in (term.KEY_ENTER,
                                                 term.KEY_DOWN,):
            # scroll forward 1 line
            idx, offset = (idx, offset + self.screen.num_columns)
        elif inp in (u'f', u' ') or inp.code in (term.KEY_PGDOWN,):
            # scroll forward 1 page
            idx, offset = (idx + 1, offset)
        elif inp == u'b' or inp.code in (term.KEY_PGUP,):
            # scroll backward 1 page
            idx, offset = (max(0, idx - 1), offset)
        elif inp.code in (term.KEY_SDOWN,):
            # scroll forward 10 pages
            idx, offset = (max(0, idx + 10), offset)
        elif inp.code in (term.KEY_SUP,):
            # scroll forward 10 pages
            idx, offset = (max(0, idx - 10), offset)
        elif inp.code == term.KEY_HOME:
            # top
            idx, offset = (0, 0)
        elif inp.code == term.KEY_END:
            # bottom
            idx, offset = (self.last_page, 0)
        return idx, offset
36596
def _enter(self):
        """"""
        command = self.command
        logger.log(5, "Snippet keystroke `Enter`.")
        # NOTE: we need to set back the actions (mode_off) before running
        # the command.
        self.mode_off()
        self.run(command)
949386
def highlight_matches(self):
        """"""
        if self.is_code_editor and self.highlight_button.isChecked():
            text = self.search_text.currentText()
            words = self.words_button.isChecked()
            regexp = self.re_button.isChecked()
            self.editor.highlight_found_results(text, words=words,
                                                regexp=regexp)
1263645
def _examine_key(self, key_name, key_val, p, i, option_parsing):
        

        # if the element we reached has an executable registered, save it!
        if 'exec' in key_val:
            self.exe = key_val['exec']

        # simple bool options, save value
        if 'type' in key_val and key_val['type'] == 'bool':
            self.exe_options[key_name] = True

        # Elements wich takes arguments need special attention
        if 'argument' in key_val:

            # is there an argument (the next element)?
            if len(self.inp_cmd) > i+1:

                self.key = { 'argument': key_val['argument'] }

                # there is - save it
                if key_val['type'] == 'option':
                    # if argument is of type multiple, store result in a list
                    if 'multiple' in key_val and key_val['multiple'] == True:
                        if key_name not in self.exe_options:
                            self.exe_options[key_name] = []
                        self.exe_options[key_name].append(self.inp_cmd[i+1])
                    else:
                        self.exe_options[key_name] = self.inp_cmd[i+1]
                else:
                    self.arg = self.inp_cmd[i+1]

                # Validate the argument if possible
                if 'validator' in key_val['argument']:
                    self.key_complete = key_val['argument']['validator'](self.inp_cmd[i+1])
                else:
                    self.key_complete = True

                # if there are sub parameters, add them
                if 'children' in key_val:
                    self.children = key_val['children']

                # If we reached a command without parameters (which
                # should be the end of the command), unset the children
                # dict.
                elif key_val['type'] == 'command':
                    self.children = None

                # if the command is finished (there is an element after the argument) and
                # there is an exec_immediately-function, execute it now
                if 'exec_immediately' in key_val and len(self.inp_cmd) > i+2:
                    key_val['exec_immediately'](self.inp_cmd[i+1], self.exe_options)
                    # clear exe_options as these were options for exec_immediately
                    self.exe_options = {}

                i += 1

            else:
                # if there is no next element, let key_complete be true
                # and set children to the option argument
                self.children = { 'argument': key_val['argument'] }

            # remove option from further tab completion as it has been filled in,
            # unless it has the 'multiple' key set, which means it can be filled
            # in multiple types and will return a list of all values
            if option_parsing and p == key_name and key_name in self.children:
                # if multiple, then pass
                if 'multiple' in self.children[key_name] and self.children[key_name]['multiple'] == True:
                    pass
                else:
                    del self.children[key_name]


        # otherwise we are handling a command without arguments
        else:

            # Rest arguments?
            if 'rest_argument' in key_val:

                self._scoop_rest_arguments = True
                self.arg = []

            self.children = key_val.get('children')
            if self.exe is not None:
                option_parsing = True

        return i, option_parsing
943412
public boolean keyMatch(String lookupKey) {
		if (key.isEmpty()) {
			return technicalName.contains(lookupKey);
		}
		else {
			return key.contains(lookupKey);
		}
	}
1061026
function checkKeyCodes (
  eventKeyCode,
  key,
  builtInAlias
) {
  var keyCodes = config.keyCodes[key] || builtInAlias;
  if (Array.isArray(keyCodes)) {
    return keyCodes.indexOf(eventKeyCode) === -1
  } else {
    return keyCodes !== eventKeyCode
  }
}
365868
def matching_pubkey
      Pubkey.all
        .detect { |key| key.verify(self) }
        .tap { |key| self.pubkey = key }
    end
75611
def keystroke(*keys)
      return if keys.empty?

      keybd_event keys.first, 0, KEYBD_EVENT_KEYDOWN, 0
      sleep KEYBD_KEYDELAY
      keystroke *keys[1..-1]
      sleep KEYBD_KEYDELAY
      keybd_event keys.first, 0, KEYBD_EVENT_KEYUP, 0
    end
759559
def button_press(self, terminal, event):
        
        self.matched_value = ''
        if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) >= (0, 46):
            matched_string = self.match_check_event(event)
        else:
            matched_string = self.match_check(
                int(event.x / self.get_char_width()), int(event.y / self.get_char_height())
            )

        self.found_link = None

        if event.button == 1 and (event.get_state() & Gdk.ModifierType.CONTROL_MASK):
            if (Vte.MAJOR_VERSION, Vte.MINOR_VERSION) > (0, 50):
                s = self.hyperlink_check_event(event)
            else:
                s = None
            if s is not None:
                self._on_ctrl_click_matcher((s, None))
            elif self.get_has_selection():
                self.quick_open()
            elif matched_string and matched_string[0]:
                self._on_ctrl_click_matcher(matched_string)
        elif event.button == 3 and matched_string:
            self.found_link = self.handleTerminalMatch(matched_string)
            self.matched_value = matched_string[0]
133490
def check_keyname(self, rule):
        """"""

        keynames = rule.get('keynames')
        if not keynames:
            self.logdebug('no keynames requirement.\n')
            return True
        if not isinstance(keynames, list):
            keynames = [keynames]

        if self.keyname in keynames:
            self.logdebug('keyname "%s" matches rule.\n' % self.keyname)
            return True
        else:
            self.logdebug('keyname "%s" does not match rule.\n' % self.keyname)
            return False
1236696
function(charCode) {
   	   for (var i=0, length=numKeyCodes.length; i < length; i++) {
   	      if (charCode == numKeyCodes[i]) return true;
   	   }
   	   return false;       
	   }
910447
def _process_keystroke_commands(self, inp):
        """"""
        if inp in (u'1', u'2'):
            # chose 1 or 2-character wide
            if int(inp) != self.screen.wide:
                self.screen.wide = int(inp)
                self.on_resize(None, None)
        elif inp in (u'_', u'-'):
            # adjust name length -2
            nlen = max(1, self.screen.style.name_len - 2)
            if nlen != self.screen.style.name_len:
                self.screen.style.name_len = nlen
                self.on_resize(None, None)
        elif inp in (u'+', u'='):
            # adjust name length +2
            nlen = min(self.term.width - 8, self.screen.style.name_len + 2)
            if nlen != self.screen.style.name_len:
                self.screen.style.name_len = nlen
                self.on_resize(None, None)
        elif inp == u'2' and self.screen.wide != 2:
            # change 2 or 1-cell wide view
            self.screen.wide = 2
            self.on_resize(None, None)
1161225
def _check_for_mismatches(self, known_keys):
        """"""
        for a_value_source in self.values_source_list:
            try:
                if a_value_source.always_ignore_mismatches:
                    continue
            except AttributeError:
                # ok, this values source doesn't have the concept
                # always igoring mismatches, we won't tolerate mismatches
                pass
            # we want to fetch the keys from the value sources so that we can
            # check for mismatches.  Commandline value sources, are different,
            # we never want to allow unmatched keys from the command line.
            # By detecting if this value source is a command line source, we
            # can employ the command line's own mismatch detection.  The
            # boolean 'allow_mismatches' controls application of the tollerance
            # for mismatches.
            if hasattr(a_value_source, 'command_line_value_source'):
                allow_mismatches = False
            else:
                allow_mismatches = True
            # make a set of all the keys from a value source in the form
            # of strings like this: 'x.y.z'
            value_source_mapping = a_value_source.get_values(
                self,
                allow_mismatches,
                self.value_source_object_hook
            )
            value_source_keys_set = set([
                k for k in
                DotDict(value_source_mapping).keys_breadth_first()
            ])
            # make a set of the keys that didn't match any of the known
            # keys in the requirements
            unmatched_keys = value_source_keys_set.difference(known_keys)
            # some of the unmatched keys may actually be ok because the were
            # used during acquisition.
            # remove keys of the form 'y.z' if they match a known key of the
            # form 'x.y.z'
            for key in unmatched_keys.copy():
                key_is_okay = six.moves.reduce(
                    lambda x, y: x or y,
                    (known_key.endswith(key) for known_key in known_keys)
                )
                if key_is_okay:
                    unmatched_keys.remove(key)
            # anything left in the unmatched_key set is a badly formed key.
            # issue a warning
            if unmatched_keys:
                if self.option_definitions.admin.strict.default:
                    # raise hell...
                    if len(unmatched_keys) > 1:
                        raise NotAnOptionError(
                            "%s are not valid Options" % unmatched_keys
                        )
                    elif len(unmatched_keys) == 1:
                        raise NotAnOptionError(
                            "%s is not a valid Option" % unmatched_keys.pop()
                        )
                else:
                    warnings.warn(
                        'Invalid options: %s' % ', '.join(sorted(unmatched_keys))
                    )