|
-
July 12th, 2008, 01:17 AM
#1
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).
Last edited by quantass; July 12th, 2008 at 01:39 AM.
-
July 12th, 2008, 03:59 AM
#2
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.
-
July 12th, 2008, 07:14 AM
#3
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?
-
July 13th, 2008, 01:15 AM
#4
Re: Get Key Input without having to hit Return Key Possible? (C# 1.1)
 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!
-
July 13th, 2008, 03:39 AM
#5
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
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
-
July 13th, 2008, 07:22 AM
#6
Re: How do i get keycodes without having to press RETURN key (C# 1.1)
 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.
-
July 13th, 2008, 11:15 AM
#7
Re: How do i get keycodes without having to press RETURN key (C# 1.1)
 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 )
 Jonny Poet
To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
If anyone felt he has got help, show it in rating the post.
Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
My latest articles :
Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|