www.digitalmars.com         C & C++   DMDScript  

c++ - How the access the HOME END keys in a console application

reply Ed Schroder <matador home.nl> writes:
As the title says.....

Under DOS I was used to get access to the HOME / END / DEL / PAGE-
UP etc. keys using the _bios_keybrd(0) function. This function is
not available in a console application.

So how does one get access?

TIA

Ed
Jan 05 2007
next sibling parent Walter Bright <newshound digitalmars.com> writes:
Ed Schroder wrote:
 As the title says.....
 
 Under DOS I was used to get access to the HOME / END / DEL / PAGE-
 UP etc. keys using the _bios_keybrd(0) function. This function is
 not available in a console application.
 
 So how does one get access?
Download ftp://ftp.digitalmars.com/me.zip, which has example code in it to do that.
Jan 05 2007
prev sibling parent reply Bertel Brander <bertel post4.tele.dk> writes:
Ed Schroder skrev:
 As the title says.....
 
 Under DOS I was used to get access to the HOME / END / DEL / PAGE-
 UP etc. keys using the _bios_keybrd(0) function. This function is
 not available in a console application.
#include <windows.h> #include <iostream> HANDLE StdIn = GetStdHandle(STD_INPUT_HANDLE); WORD GetChar() { DWORD NumEventsRead; INPUT_RECORD InputRecord; while(1) { if(!ReadConsoleInput(StdIn, &InputRecord, 1, &NumEventsRead)) return 0; if(InputRecord.EventType & KEY_EVENT && InputRecord.Event.KeyEvent.bKeyDown) { if(InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_CONTROL && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_MENU && InputRecord.Event.KeyEvent.wVirtualKeyCode != VK_SHIFT) { return InputRecord.Event.KeyEvent.wVirtualKeyCode; } } } } int main() { std::cout << "Hit Esc to exit" << std::endl; WORD Ch; while((Ch = GetChar()) != VK_ESCAPE) { switch(Ch) { case VK_END: std::cout << "End" << std::endl; break; case VK_HOME: std::cout << "Home" << std::endl; break; } } } -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 05 2007
parent Ed Schroder <matador home.nl> writes:
Got it working..... thx Bertil & Walter!

Regards,

Ed
Jan 05 2007