https://github.com/zewenn/zig-ascii-input
An ASCII input library for console applications written in zig
https://github.com/zewenn/zig-ascii-input
Last synced: 11 months ago
JSON representation
An ASCII input library for console applications written in zig
- Host: GitHub
- URL: https://github.com/zewenn/zig-ascii-input
- Owner: zewenn
- Created: 2024-08-12T08:49:18.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-22T09:02:10.000Z (almost 2 years ago)
- Last Synced: 2025-01-21T13:34:28.044Z (over 1 year ago)
- Language: Zig
- Size: 19 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
> [!CAUTION]
> This library is **DEPRECATED** and will not be supported further.
# Zig Termnal Input Library
> [!WARNING]
> This library currently only supports Linux and MacOS
## How to use?
```zig
zinput.init(&allocator);
```
> [!IMPORTANT]
> This will set the terminal to **RAW** mode, make sure to call `zinput.deinit()` to change it back to cooked mode!
```zig
for (zinput.getKeys()) |key| switch (key) {
zinput.keys.ESCAPE => break :game_loop,
else => {},
};
```
By calling the `zinput.getKeys()` function, you will get a `u8` buffer with all the keys pressed on that frame.
> [!WARNING]
> This only works with new keypresses, only one key can be held down.