An open API service indexing awesome lists of open source software.

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

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.