keypressmgr.py
def bind(self, key, func, # {{{1
           timeout=0,
           keys=None,
           on=p.KEY_WAS_TRIGGERED,
           repeat=False,
           modifiers=(),
           args=None, kwargs=None):
    """Bind a key to a function. Arguments:
    key         The key code to listen for; may be either a string or a code
    func        The function to call
    timeout     Time in seconds to ignore repeated key presses (default 0)
    keys        Pass the keys dict as the first arg to func (default False)
    on          Bit mask of required key states (default p.KEY_WAS_TRIGGERED)
    repeat      Handle a key being held down continuously (default False)
    modifiers   Tuple of required modifier keys (B3G_SHIFT, B3G_CONTROL, etc)
    args        Extra positional args to pass to func
    kwargs      Extra keyword arguments to pass to func

    repeat=True is identical to `on = on | p.KEY_IS_DOWN`

    If keys==True, then func will be called as
      func(keys, *args, **kwargs)
    Otherwise, func will be called as
      func(*args, **kwargs)
    """
    fArgs = []
    fKwargs = {}
    if args is not None:
      fArgs.extend(args)
    if kwargs is not None:
      fKwargs.update(kwargs)
    if key in self._maps:
      key = self._maps[key]
    keycode, keymods = parseKey(key)
    kb = {
      "key": keycode,
      "func": func,
      "states": on | (p.KEY_IS_DOWN if repeat else 0),
      "timeout": timeout,
      "lastPress": 0,
      "wantKeyInfo": keys,
      "modifiers": tuple(keymods) + tuple(modifiers),
      "extraArgs": fArgs,
      "extraKwargs": fKwargs
    }
    if self._debug:
      # Print information about the keybind
      logger.debug("Bound {}".format(self.kbToString(kb)))
    self._binds.append(kb)
Bind a key to a function. Arguments:
    key         The key code to listen for; may be either a string or a code
    func        The function to call
    timeout     Time in seconds to ignore repeated key presses (default 0)
    keys        Pass the keys dict as the first arg to func (default False)
    on          Bit mask of required key states (default p.KEY_WAS_TRIGGERED)
    repeat      Handle a key being held down continuously (default False)
    modifiers   Tuple of required modifier keys (B3G_SHIFT, B3G_CONTROL, etc)
    args        Extra positional args to pass to func
    kwargs      Extra keyword arguments to pass to func

    repeat=True is identical to `on = on | p.KEY_IS_DOWN`

    If keys==True, then func will be called as
      func(keys, *args, **kwargs)
    Otherwise, func will be called as
      func(*args, **kwargs)
    
Bind a key to a function. Arguments:
key         The key code to listen for; may be either a string or a code
func        The function to call
timeout     Time in seconds to ignore repeated key presses (default 0)
keys        Pass the keys dict as the first arg to func (default False)
on          Bit mask of required key states (default p.KEY_WAS_TRIGGERED)
repeat      Handle a key being held down continuously (default False)
modifiers   Tuple of required modifier keys (B3G_SHIFT, B3G_CONTROL, etc)
args        Extra positional args to pass to func
kwargs      Extra keyword arguments to pass to func

repeat=True is identical to `on = on | p.KEY_IS_DOWN`


Bind a key to a function . Arguments : key The key code to listen for ; may be either a string or a code func The function to call timeout Time in seconds to ignore repeated key presses ( default 0 ) keys Pass the keys dict as the first arg to func ( default False ) on Bit mask of required key states ( default p . KEY_WAS_TRIGGERED ) repeat Handle a key being held down continuously ( default False ) modifiers Tuple of required modifier keys ( B3G_SHIFT B3G_CONTROL etc ) args Extra positional args to pass to func kwargs Extra keyword arguments to pass to func repeat = True is identical to ` on = on | p . KEY_IS_DOWN `
def bind(self, key, func, 
           timeout=0,
           keys=None,
           on=p.KEY_WAS_TRIGGERED,
           repeat=False,
           modifiers=(),
           args=None, kwargs=None):
    fArgs = []
    fKwargs = {}
    if args is not None:
      fArgs.extend(args)
    if kwargs is not None:
      fKwargs.update(kwargs)
    if key in self._maps:
      key = self._maps[key]
    keycode, keymods = parseKey(key)
    kb = {
      "key": keycode,
      "func": func,
      "states": on | (p.KEY_IS_DOWN if repeat else 0),
      "timeout": timeout,
      "lastPress": 0,
      "wantKeyInfo": keys,
      "modifiers": tuple(keymods) + tuple(modifiers),
      "extraArgs": fArgs,
      "extraKwargs": fKwargs
    }
    if self._debug:
      logger.debug("Bound {}".format(self.kbToString(kb)))
    self._binds.append(kb)
def bind ( self , key , func , timeout = 0 , keys = None , on = p . KEY_WAS_TRIGGERED , repeat = False , modifiers = ( ) , args = None , kwargs = None ) : fArgs = [ ] fKwargs = { } if args is not None : fArgs . extend ( args ) if kwargs is not None : fKwargs . update ( kwargs ) if key in self . _maps : key = self . _maps [ key ] keycode , keymods = parseKey ( key ) kb = { "key" : keycode , "func" : func , "states" : on | ( p . KEY_IS_DOWN if repeat else 0 ) , "timeout" : timeout , "lastPress" : 0 , "wantKeyInfo" : keys , "modifiers" : tuple ( keymods ) + tuple ( modifiers ) , "extraArgs" : fArgs , "extraKwargs" : fKwargs } if self . _debug : logger . debug ( "Bound {}" . format ( self . kbToString ( kb ) ) ) self . _binds . append ( kb )
Bind a key to a function.
Bind a key to a function .
# {{{1 """Bind a key to a function. Arguments:
    key         The key code to listen for; may be either a string or a code
    func        The function to call
    timeout     Time in seconds to ignore repeated key presses (default 0)
    keys        Pass the keys dict as the first arg to func (default False)
    on          Bit mask of required key states (default p.KEY_WAS_TRIGGERED)
    repeat      Handle a key being held down continuously (default False)
    modifiers   Tuple of required modifier keys (B3G_SHIFT, B3G_CONTROL, etc)
    args        Extra positional args to pass to func
    kwargs      Extra keyword arguments to pass to func

    repeat=True is identical to `on = on | p.KEY_IS_DOWN`

    If keys==True, then func will be called as
      func(keys, *args, **kwargs)
    Otherwise, func will be called as
      func(*args, **kwargs)
    """ # Print information about the keybind
self
key
func
timeout
keys
on
repeat
modifiers
args
kwargs