kbhit() is present in conio.h and used to determine if a key has been pressed or not. To use kbhit function in your program you should include the header file “conio.h”. If a key has been pressed then it returns a non zero value otherwise returns zero.
"Press a key" will keep printing on the console until the user presses a key on the keyboard.
Note : kbhit() is not a standard library function and should be avoided.
Program to fetch the pressed key using kbhit
Prints all the keys that will be pressed on the keyboard until the user presses Escape key
This article is contributed by Nishu Singh 1. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Difference Between C Language and LISP Language
- C Programming Language Standard
- A C Programming Language Puzzle
- Tips and Tricks for Competitive Programmers | Set 2 (Language to be used for Competitive Programming)
- C Language Introduction
- Arrays in C Language | Set 2 (Properties)
- Why C++ is partially Object Oriented Language?
- Convert C/C++ code to assembly language
- Signals in C language
- Constants vs Variables in C language
- Difference between %d and %i format specifier in C language
- lvalue and rvalue in C language
- Difference between while(1) and while(0) in C language
- Set position with seekg() in C++ language file handling
- How to use POSIX semaphores in C language
- Benefits of C language over other programming languages
- fgets() and gets() in C language
- isxdigit() function in C Language
- isupper() function in C Language
- isalnum() function in C Language
Improved By : sahivam4u