From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: ALLEGRO: Keyboard reading help... Date: Wed, 25 Jun 1997 19:40:40 +0100 Organization: None Distribution: world Message-ID: References: <33b061c3 DOT 10229116 AT usenet DOT nau DOT edu> NNTP-Posting-Host: talula.demon.co.uk MIME-Version: 1.0 Lines: 55 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Michael D. Ryan writes: >I want to be able to interpret an alt code from the keyboard using >allegro. I have tried doing it the way it says in the allegro.txt and >it doesn't work. > >EX: > >int ch, int key; That's not valid C, so it can't be the exact program you were testing! When asking for help about a problem, please make sure you post something that you've actually run, so you are sure that it does indeed demonstrate the trouble. Of course it's a good idea to strip the guilty routine down to an absolute minimum, but if you leave essential things out or just post a sort-of-similar routine, it's very likely that some silly typo like this will end up leaving out the one line that actually contains your problem... >key = KEY_F; >ch = readkey(); >if (ch == (key << 8)) do_whatever(); >else didnt_work(); > >It doesn't seem to recognize the keys. I have tried a whole bunch of >different combinations and no luck. Looks fine to me. This almost identical program works correctly on my machine, so your mistake must be in the bits of code that you didn't post... #include #include int main() { int ch, key; allegro_init(); install_keyboard(); key = KEY_F; ch = readkey(); if (ch == (key << 8)) printf("alt+F was pressed!\n"); else printf("Something else was pressed!\n"); return 0; } -- Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/ Beauty is a French phonetic corruption of a short cloth neck ornament.