Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
/* * This file is part of the FBK C code Examples distribution (https://filmsbyrkis.com). * Copyright (c) 2022 Kris Occhipinti. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, version 3. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see
. */ // This displays keys being pressed // WASD will show UP, LEFT, DOWN, RIGHT //Dependencies: // sudo apt-get install libncurses5-dev libncursesw5-dev //Compile: // gcc main.c -o main -W -Wall -Werror -Wextra -lncurses #include
#include
void get_char(); int main(void) { get_char(); return 0; } void get_char() { while (1){ initscr(); // mandatory curses init cbreak(); // unbuffered input int chr; do { chr = getch(); clear(); } while (chr == ERR); if(chr == 97){ printw("LEFT\n"); } else if(chr == 100){ printw("RIGHT\n"); } else if(chr == 115){ printw("DOWN\n"); } else if(chr == 119){ printw("UP\n"); } else { printw("chr = %i\n", chr); } refresh(); // show the printf stuff } endwin(); // curses cleanup }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)