1. Keyboard Trapper
- Posted by mistertrik at hotmail.com Feb 05, 2002
- 426 views
When programming a game in dos, (ex.exe) I found that when you call get_key() it will only return the last key pressed. That is all well and good for simple things. However, in say a driving game the user will want to hold the accelerator on whilst going round a corner (ie need two keys at once reported). The perfect solution would be a function that returned a string containing all keys being held down at that time, and something that would detect the shift, ctrl etc keys (maybe have special codes for them). I.e. code ... s = get_key_string() --s is now a sequence if find(UP, s) then accel() elsif find(DOWN, s) then brake() elsif find(LEFT, s) then turn(-1) elsif find(RIGHT, s) then turn(1) end if ... /code Now does any such function exist? or anything like it? I also need a function like that for a virtual perkins brailler that I am working on. ===================================================== .______<-------------------\__ / _____<--------------------__|=== ||_ <-------------------/ \__| Mr Trick
2. Re: Keyboard Trapper
- Posted by Jiri Babor <jbabor at PARADISE.NET.NZ> Feb 06, 2002
- 436 views
Have a look at Michael Bolin's keyboard handler in the Archives, keyread.zip. It contains a single file, module keyread.e. jiri ----- Original Message ----- From: <mistertrik at hotmail.com> To: "EUforum" <EUforum at topica.com> Subject: Keyboard Trapper > > When programming a game in dos, (ex.exe) I found that when you call > get_key() it will only return the last key pressed. That is all well and > good for simple things. > However, in say a driving game the user will want to hold the > accelerator on whilst going round a corner (ie need two keys at once > reported). > The perfect solution would be a function that returned a string > containing all keys being held down at that time, and something that would > detect the shift, ctrl etc keys (maybe have special codes for them). I.e. > > code > ... > s = get_key_string() --s is now a sequence > if find(UP, s) then > accel() > elsif find(DOWN, s) then > brake() > elsif find(LEFT, s) then > turn(-1) > elsif find(RIGHT, s) then > turn(1) > end if > ... > /code > > Now does any such function exist? or anything like it? > I also need a function like that for a virtual perkins brailler that I am > working on. > ===================================================== > .______<-------------------\__ > / _____<--------------------__|=== > ||_ <-------------------/ > \__| Mr Trick > > > >