This commit is contained in:
Firepup Sixfifty 2021-11-17 15:58:36 +00:00
parent cd7000d955
commit 5006fde8a5
10 changed files with 91 additions and 5 deletions

View file

@ -0,0 +1,5 @@
# fkeycapture
This is a simple and easy to use package that allows you to capture individual keystrokes from the user.
#### Forms:
1. (Default) Recive key as a string
2. Recive key as bytes

Binary file not shown.

Binary file not shown.

View file

@ -1,19 +1,23 @@
[metadata] [metadata]
name = fkeycapture-ALEXANDERMAPLES name = fkeycapture-Firepup650
version = 0.0.1 version = 0.0.1
author = ALEXANDERMAPLES author = Firepup650
author_email = firepyp650@gmail.com author_email = firepyp650@gmail.com
description = A way to capture keystrokes description = A way to capture keystrokes
long_description = file: README.md long_description = file: README.md
long_description_content_type = text/markdown long_description_content_type = text/markdown
url = https://github.com/pypa/sampleproject url = https://github.com/Alexander-Maples/fkeycapture
project_urls = project_urls =
Bug Tracker = https://github.com/pypa/sampleproject/issues Bug Tracker = https://github.com/Alexander-Maples/fkeycapture/issues
Main = https://replit.com/@ALEXANDERMAPLES/fkeycapture replit = https://replit.com/@ALEXANDERMAPLES/fkeycapture
classifiers = classifiers =
Programming Language :: Python :: 3 Programming Language :: Python :: 3
License :: OSI Approved :: MIT License License :: OSI Approved :: MIT License
Operating System :: OS Independent Operating System :: OS Independent
Development Status :: 4 - Beta
Environment :: Console
Intended Audience :: Developers
Natural Language :: English
[options] [options]
package_dir = package_dir =

View file

View file

@ -0,0 +1,37 @@
import termios, fcntl, sys
fd = sys.stdin.fileno()
flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
attrs_save = termios.tcgetattr(fd)
def getp1():
import termios, fcntl, sys, os
fd = sys.stdin.fileno()
# save old state
flags_save = fcntl.fcntl(fd, fcntl.F_GETFL)
attrs_save = termios.tcgetattr(fd)
# make raw - the way to do this comes from the termios(3) man page.
attrs = list(attrs_save) # copy the stored version to update
# iflag
attrs[0] &= ~(termios.IGNBRK | termios.BRKINT | termios.PARMRK
| termios.ISTRIP | termios.INLCR | termios. IGNCR
| termios.ICRNL | termios.IXON )
# oflag
attrs[1] &= ~termios.OPOST
# cflag
attrs[2] &= ~(termios.CSIZE | termios. PARENB)
attrs[2] |= termios.CS8
# lflag
attrs[3] &= ~(termios.ECHONL | termios.ECHO | termios.ICANON
| termios.ISIG | termios.IEXTEN)
termios.tcsetattr(fd, termios.TCSANOW, attrs)
# turn off non-blocking
fcntl.fcntl(fd, fcntl.F_SETFL, flags_save & ~os.O_NONBLOCK)
def getp2():
termios.tcsetattr(fd, termios.TCSAFLUSH, attrs_save)
fcntl.fcntl(fd, fcntl.F_SETFL, flags_save)
def get(keycount=1,bytes=False):
getp1()
key = sys.stdin.read(keycount)
getp2()
if bytes == True:
key = key.encode()
return key

View file

@ -0,0 +1,28 @@
Metadata-Version: 2.1
Name: fkeycapture-Firepup650
Version: 0.0.1
Summary: A way to capture keystrokes
Home-page: https://github.com/Alexander-Maples/fkeycapture
Author: Firepup650
Author-email: firepyp650@gmail.com
License: UNKNOWN
Project-URL: Bug Tracker, https://github.com/Alexander-Maples/fkeycapture/issues
Project-URL: replit, https://replit.com/@ALEXANDERMAPLES/fkeycapture
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
# fkeycapture
This is a simple and easy to use package that allows you to capture individual keystrokes from the user.
#### Forms:
1. (Default) Recive key as a string
2. Recive key as bytes

View file

@ -0,0 +1,10 @@
LICENSE
README.md
pyproject.toml
setup.cfg
src/fkeycapture/__init__.py
src/fkeycapture/fkeycapture.py
src/fkeycapture_Firepup650.egg-info/PKG-INFO
src/fkeycapture_Firepup650.egg-info/SOURCES.txt
src/fkeycapture_Firepup650.egg-info/dependency_links.txt
src/fkeycapture_Firepup650.egg-info/top_level.txt

View file

@ -0,0 +1 @@
fkeycapture