Design Pattern Examples
Overview of object-oriented design patterns
checkforkey.c
Go to the documentation of this file.
1
5
6#ifdef _MSC_VER
7#include <conio.h>
8#else
9#include <unistd.h>
10#include <sys/time.h>
11#endif
12
13#include "checkforkey.h"
14
15#ifndef _MSC_VER
16int kbhit (void)
17{
18 struct timeval tv;
19 fd_set rdfs;
20
21 tv.tv_sec = 0;
22 tv.tv_usec = 0;
23
24 FD_ZERO(&rdfs);
25 FD_SET (STDIN_FILENO, &rdfs);
26
27 select(STDIN_FILENO+1, &rdfs, NULL, NULL, &tv);
28 return FD_ISSET(STDIN_FILENO, &rdfs);
29
30}
31#endif
32
33
39bool checkforkey(void)
40{
41#ifdef _MSC_VER
42 return _kbhit() != 0;
43#else
44 return kbhit() != 0;
45#endif
46}
int kbhit(void)
Definition: checkforkey.c:16
bool checkforkey(void)
Determine if a key has been pressed.
Definition: checkforkey.c:39
Declaration of the checkforkey() function for determining if a key has been pressed.