How do i get keycodes without having to press RETURN key (C# 1.1)
I notice that in 1.1 there seems to be no way to get the user's key input, using the System.Console class's Read() function, without first hitting the enter key. I looked for other functions and in other classes and it doesnt seem possible in 1.1 ... How can something so basic and obvious be overlooked in 1.1 .. I do know that in 2.0+ ms finally added a ReadKey() function...
Does anyone have an coding alternative for 1.1 users? (and saying: "upgrade" isnt what i am looking for).
Re: Get Key Input without having to hit Return Key Possible? (C# 1.1)
If you're looking for UI, use a form. You are in a Window's environment you know - that's what windows are there for.
Darwen.
Re: Get Key Input without having to hit Return Key Possible? (C# 1.1)
Emm... I'm not so sure weater .NET 1.1 support it, but System.Runtime.InteropServices.Win32Interop._kbhit() returns 0 if a key was pressed or the key code otherwise.
Code:
using System.Runtime.InteropServices.Win32Interop;
...
[DllImport("crtdll.dll")]
public static extern int _kbhit();
...
char ch;
while((ch = _kbhit()) != 0);
Console.WriteLine(ch.ToString());
Helps somehow?
Re: Get Key Input without having to hit Return Key Possible? (C# 1.1)
Quote:
Originally Posted by Talikag
Emm... I'm not so sure weater .NET 1.1 support it, but System.Runtime.InteropServices.Win32Interop._kbhit() returns 0 if a key was pressed or the key code otherwise.
Code:
using System.Runtime.InteropServices.Win32Interop;
...
[DllImport("crtdll.dll")]
public static extern int _kbhit();
...
char ch;
while((ch = _kbhit()) != 0);
Console.WriteLine(ch.ToString());
Helps somehow?
THanks for taking the time to not only read my question but provide a useful answer!
Re: How do i get keycodes without having to press RETURN key (C# 1.1)
Maybe a thumb question: Why not simple upgrading to minimum 2.0 Framework. You now we already have 3.5 there
Re: How do i get keycodes without having to press RETURN key (C# 1.1)
Quote:
Originally Posted by JonnyPoet
Maybe a thumb question: Why not simple upgrading to minimum 2.0 Framework. You now we already have 3.5 there
I was about to answer this question but realized there are numerous answers among my specific concern but then figured your question might have been rhetorical in nature and so i will just say a big thanks to Talitag for the assistance and by not resorting to what could have been the obvious.
Re: How do i get keycodes without having to press RETURN key (C# 1.1)
Quote:
Originally Posted by quantass
I was about to answer this question but realized there are numerous answers among my specific concern but then figured your question might have been rhetorical in nature and so i will just say a big thanks to Talitag for the assistance and by not resorting to what could have been the obvious.
No it wasn't really rethorical only, I wanted to suggest you that you really should think about this point. Maybe you have good reasons and I didn't expect to get all of them answered here, but is it a big deal to do so in your program ? ( for example changes in multithreading code behaviour )