https://github.com/sikofitt/getch_c
This is an attempt at replicating the non standard _getch function for windows from conio.h on linux
https://github.com/sikofitt/getch_c
c getch linux termios windows-alternative
Last synced: about 1 month ago
JSON representation
This is an attempt at replicating the non standard _getch function for windows from conio.h on linux
- Host: GitHub
- URL: https://github.com/sikofitt/getch_c
- Owner: sikofitt
- License: mpl-2.0
- Created: 2021-02-22T23:38:11.000Z (over 5 years ago)
- Default Branch: 1.x
- Last Pushed: 2021-03-01T17:42:28.000Z (over 5 years ago)
- Last Synced: 2025-01-06T01:27:05.253Z (over 1 year ago)
- Topics: c, getch, linux, termios, windows-alternative
- Language: C++
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Getch for linux
This is an attempt at replicating the non standard _getch function for windows from conio.h on linux
It should work mostly the same as the windows function.
For special keys you need to call _getch twice. The first time it will return either a 0 or 0xE0 (224) depending on the key pressed.
See https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/getch-getwch?view=msvc-160#remarks
Difference is that _getch will read CTRL+C, or any control characters.
There is also an extra function `int cinPeek()` that returns the next character in stdin without removing it.
### Note
Make sure that the user calling the function is in the group "input"
Only tested on Gentoo with XTerm and /dev/tty?.