Mention index, get and the fact that all but ALPHA keys are case-sensitive to docs

This commit is contained in:
John Morrison 2022-04-25 17:51:00 +01:00 committed by xs5871
parent 7d46e701aa
commit 8950e45325

View File

@ -99,7 +99,7 @@ All of these methods take the same arguments, and for this, I'll lift a
docstring straight out of the source:
> Receives the following:
>
>
> - self (this Key instance)
> - state (the current InternalState)
> - KC (the global KC lookup table, for convenience)
@ -107,10 +107,10 @@ docstring straight out of the source:
> for the pressed key - this is likely not useful to end users, but is
> provided for consistency with the internal handlers)
> - `coord_raw` (an X,Y tuple of the matrix coordinate - also likely not useful)
>
>
> The return value of the provided callback is discarded. Exceptions are _not_
> caught, and will likely crash KMK if not handled within your function.
>
>
> These handlers are run in attachment order: handlers provided by earlier
> calls of this method will be executed before those provided by later calls.
@ -153,7 +153,7 @@ def shrek(*args, **kwargs):
print('⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀⠀⠀⠀⠀⠀⠀⠀')
print('⠀⠀⠀⠀⠀⠀⠀⠹⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀')
print('⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠛⠻⠿⠿⠿⠿⠛⠉')
return False #Returning True will follow thru the normal handlers sending the ALT key to the OS
KC.LALT.before_press_handler(shrek)
```
@ -166,3 +166,18 @@ have my handlers attached:
```python
SHREKLESS_ALT = KC.LALT.clone()
```
You can also refer to a key by index:
* KC['A']
* KC['NO']
* KC['LALT']
or the get function which has an optional argument of `default`. `default` is
be returned if the key is not found (`None` unless otherwise specified):
* KC.get('A')
* KC.get('NO', None)
* KC.get('NOT DEFINED', KC.RALT)
Keys names are case-sensitive. KC['NO'] being different from KC['no']. It is recommended
that names are capitalised typically. The exception to this is alphabetical; KC['A'] and
KC['a'] will both return the same, unshifted, key.