PyKeyeasy 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- PyKey/__init__.py +21 -0
- PyKey/core.py +73 -0
- pykeyeasy-1.0.0.dist-info/METADATA +46 -0
- pykeyeasy-1.0.0.dist-info/RECORD +7 -0
- pykeyeasy-1.0.0.dist-info/WHEEL +5 -0
- pykeyeasy-1.0.0.dist-info/licenses/LICENSE +21 -0
- pykeyeasy-1.0.0.dist-info/top_level.txt +1 -0
PyKey/__init__.py
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PyKeys - The simplest keyboard detection library for humans.
|
|
3
|
+
Developed by: Emiliano
|
|
4
|
+
Version: 1.0.0
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .core import PyKey
|
|
8
|
+
|
|
9
|
+
__docs__ = """
|
|
10
|
+
PyKeys is a library designed to simplify keyboard detection using a background monitor.
|
|
11
|
+
It provides three main variables that update automatically:
|
|
12
|
+
- PyKey.key: For regular letters and numbers.
|
|
13
|
+
- PyKey.F: For function keys (F1-F12).
|
|
14
|
+
- PyKey.hotkey: For key combinations (Ctrl, Alt, etc.) or special keys.
|
|
15
|
+
|
|
16
|
+
Basic Usage:
|
|
17
|
+
from PyKeys import PyKey
|
|
18
|
+
while True:
|
|
19
|
+
if PyKey.key == 'a, s':
|
|
20
|
+
print("A and S keys are pressed in order")
|
|
21
|
+
"""
|
PyKey/core.py
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import ComicScript # Requisito de Emiliano
|
|
2
|
+
import keyboard
|
|
3
|
+
import threading
|
|
4
|
+
import time
|
|
5
|
+
|
|
6
|
+
class PyKeySystem:
|
|
7
|
+
def __init__(self):
|
|
8
|
+
self._keys_pressed_order = []
|
|
9
|
+
self.key = ""
|
|
10
|
+
self.F = ""
|
|
11
|
+
self.hotkey = ""
|
|
12
|
+
|
|
13
|
+
self._monitor_active = True
|
|
14
|
+
self._running = True
|
|
15
|
+
# Lista de control extendida
|
|
16
|
+
self.especiales = ['ctrl', 'alt', 'shift', 'windows', 'tab', 'esc', 'delete', 'insert', 'alt gr']
|
|
17
|
+
|
|
18
|
+
self._thread = threading.Thread(target=self._update_loop, daemon=True)
|
|
19
|
+
self._thread.start()
|
|
20
|
+
|
|
21
|
+
def _update_loop(self):
|
|
22
|
+
while self._running:
|
|
23
|
+
if self._monitor_active:
|
|
24
|
+
try:
|
|
25
|
+
evento = keyboard.read_event()
|
|
26
|
+
name = evento.name.lower()
|
|
27
|
+
|
|
28
|
+
if evento.event_type == keyboard.KEY_DOWN:
|
|
29
|
+
if name not in self._keys_pressed_order:
|
|
30
|
+
self._keys_pressed_order.append(name)
|
|
31
|
+
|
|
32
|
+
elif evento.event_type == keyboard.KEY_UP:
|
|
33
|
+
if name in self._keys_pressed_order:
|
|
34
|
+
self._keys_pressed_order.remove(name)
|
|
35
|
+
|
|
36
|
+
self._actualizar_variables()
|
|
37
|
+
except:
|
|
38
|
+
pass
|
|
39
|
+
time.sleep(0.001)
|
|
40
|
+
|
|
41
|
+
def _actualizar_variables(self):
|
|
42
|
+
actuales = list(self._keys_pressed_order)
|
|
43
|
+
|
|
44
|
+
# 1. Identificamos qué tipo de teclas hay en la lista
|
|
45
|
+
modificadores = [t for t in actuales if t in self.especiales]
|
|
46
|
+
efes_list = [t.upper() for t in actuales if t.startswith('f') and len(t) > 1]
|
|
47
|
+
|
|
48
|
+
# Teclas normales: NO son especiales, NO son Efes
|
|
49
|
+
normales = [t for t in actuales if t not in self.especiales and t.upper() not in efes_list]
|
|
50
|
+
|
|
51
|
+
# --- LÓGICA DE ASIGNACIÓN EXCLUSIVA ---
|
|
52
|
+
|
|
53
|
+
# 1. Prioridad Efes: Siempre a su variable
|
|
54
|
+
self.F = ", ".join(efes_list)
|
|
55
|
+
|
|
56
|
+
# 2. Lógica de Hotkey vs Key
|
|
57
|
+
if any(m in ['ctrl', 'alt', 'windows', 'shift'] for m in modificadores):
|
|
58
|
+
# Si hay un modificador de "combos", TODO se va a hotkey
|
|
59
|
+
self.hotkey = ", ".join(actuales)
|
|
60
|
+
self.key = ""
|
|
61
|
+
else:
|
|
62
|
+
# Si no hay combo, las especiales solas (Esc, Space) van a hotkey
|
|
63
|
+
self.hotkey = ", ".join(modificadores)
|
|
64
|
+
# Y las normales van a key (Aquí ya no entran las Efes por el filtro anterior)
|
|
65
|
+
self.key = ", ".join(normales)
|
|
66
|
+
|
|
67
|
+
def Monitor(self, state: bool):
|
|
68
|
+
self._monitor_active = state
|
|
69
|
+
if not state:
|
|
70
|
+
self._keys_pressed_order = []
|
|
71
|
+
self.key = self.F = self.hotkey = ""
|
|
72
|
+
|
|
73
|
+
PyKey = PyKeySystem()
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: PyKeyeasy
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Ultra-simple keyboard detection with automatic variables
|
|
5
|
+
Home-page: https://github.com/emicics/PyKeys
|
|
6
|
+
Author: Emiliano
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
11
|
+
Requires-Python: >=3.6
|
|
12
|
+
Description-Content-Type: text/markdown
|
|
13
|
+
License-File: LICENSE
|
|
14
|
+
Requires-Dist: keyboard
|
|
15
|
+
Requires-Dist: threading
|
|
16
|
+
Requires-Dist: time
|
|
17
|
+
Dynamic: author
|
|
18
|
+
Dynamic: classifier
|
|
19
|
+
Dynamic: description
|
|
20
|
+
Dynamic: description-content-type
|
|
21
|
+
Dynamic: home-page
|
|
22
|
+
Dynamic: license-file
|
|
23
|
+
Dynamic: requires-dist
|
|
24
|
+
Dynamic: requires-python
|
|
25
|
+
Dynamic: summary
|
|
26
|
+
|
|
27
|
+
This library simplifies key detection with just three simple, easy-to-call values:
|
|
28
|
+
|
|
29
|
+
PyKey.key
|
|
30
|
+
PyKey.hotkey
|
|
31
|
+
PyKey.F
|
|
32
|
+
|
|
33
|
+
Key displays the currently pressed letter key along with combinations. For example:
|
|
34
|
+
|
|
35
|
+
if PyKey.key == 'a, d':
|
|
36
|
+
print("The 'a' and 'd' keys are pressed in that order")`
|
|
37
|
+
|
|
38
|
+
for hotkeys:
|
|
39
|
+
|
|
40
|
+
if PyKey.hotkey == ctrl, d':
|
|
41
|
+
print("You pressed Ctrl+D")
|
|
42
|
+
|
|
43
|
+
and for F:
|
|
44
|
+
|
|
45
|
+
if PyKey.F == 'F5':
|
|
46
|
+
print("You pressed F5")
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
PyKey/__init__.py,sha256=HmaNCC-4U2wB0mJP5SaTT8M4c6hT5OWF7UDIxlJmfJA,606
|
|
2
|
+
PyKey/core.py,sha256=L7WtaccmkMZcqRE60I_8cQaycfcpD4kCFBXK4AgrBIU,2767
|
|
3
|
+
pykeyeasy-1.0.0.dist-info/licenses/LICENSE,sha256=ggskK-8nKtrqr5NxnJ_5PvA_xwcBBZm8xuW3YY26MiE,1084
|
|
4
|
+
pykeyeasy-1.0.0.dist-info/METADATA,sha256=OcaXIMe3xUm1v0ebjuVAYTQPAq7mF9F0xuuJNd9bg34,1194
|
|
5
|
+
pykeyeasy-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
6
|
+
pykeyeasy-1.0.0.dist-info/top_level.txt,sha256=BcWLNXdoqu1Uc5OYKQ4hT92AAcB48h14x2YnIfbwYTw,6
|
|
7
|
+
pykeyeasy-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Emiliano
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
PyKey
|