473,654 Members | 3,062 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Making a Form read keyboard input

Hi,
I've been trying to write a small windows application in C#. I want the
form to read special input sequences act accordingly. For example,
<Alt><Ctrl>H should bring up the help box etc. I tried to use the
form1_keydown event, but that doesn't seem to work.

What can be done to make it work?

Thanks in advance.

--ts

Nov 13 '06 #1
2 4154
You need to set the KeyPreview property on the form to true. This will make
it fire the Key events when it is activated.
Then you should be able to handle it as you planned.

Ciaran O'Donnell

"Srin" wrote:
Hi,
I've been trying to write a small windows application in C#. I want the
form to read special input sequences act accordingly. For example,
<Alt><Ctrl>H should bring up the help box etc. I tried to use the
form1_keydown event, but that doesn't seem to work.

What can be done to make it work?

Thanks in advance.

--ts

Nov 13 '06 #2
Ciaran O''Donnell wrote:
You need to set the KeyPreview property on the form to true. This will make
it fire the Key events when it is activated.
Then you should be able to handle it as you planned.

Ciaran O'Donnell

"Srin" wrote:
Hi,
I've been trying to write a small windows application in C#. I want the
form to read special input sequences act accordingly. For example,
<Alt><Ctrl>H should bring up the help box etc. I tried to use the
form1_keydown event, but that doesn't seem to work.

What can be done to make it work?

Thanks in advance.

--ts
Thank you Ciaran, that worked.

Nov 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4070
by: j. del | last post by:
I am just beginning to write programs... and my first task that I have set myself is to write a little program that will generate cryptic bywords from a source of text. A cryptic byword is basically a ceaser cypher but with randomly assigned letters rather than just shifted down by a value. So.. I am thinking that the BSD fortune game for the gnixes is a good source for the text to cypher. HOWEVER.. I am not sure how to read data in...
8
16337
by: Brian Keating EI9FXB | last post by:
Would I be correct in saying that the only way to get a user message into a Windows form would be to use P/Invoke with Message? Of is there some part of the .NET API that I am totally un aware of? Thanks for any help Brian
2
8123
by: Rajen | last post by:
Suppose the field length is 25 characters. After entering the 25th character, it should be available to process. Program should not wait for the user to press enter/return key. Thank you.
0
2744
by: neonspark | last post by:
I'm buidling some simple macro functionality for my app so the users can record a sequence of keyboard inputs and replay them reliably via some menu. Originally, I used: protected override bool ProcessCmdKey(ref Message msg, Keys keyData) To map "Keys" objects to their string constant, and stored them on a string Queue as they were happening. Then (after resetting the form), I simulate replaying of these actions by flushing the queued...
1
5282
by: pinkfloydhomer | last post by:
I am writing a curses application, but the getch() does not seem to give me all I want. Of course, if I press "d", it returns an ord("d") and so on. But I want to be able to detect whether alt, shift or ctrl has been pressed also. Shift is normally covered by returning an uppercase character instead and ctrl seems to return control codes (as is normal, I guess), but alt I can't detect with getch, it seems. Preferably, I would like one...
5
3126
by: bmerlover | last post by:
I currently have a gui app I programmed with visual c++ .net version. Is there any way I can read any character from the keyboard as soon as any key is pressed while the application is running? My intention is that as soon as a specific key is pressed, the app is suppose to take the appropriate action. All the functions work, so all I would have to do is call the function as soon as a key is pressed from the keyboard? I am not asking the user...
6
2223
by: Steve | last post by:
Hi All I have an on-screen keyboard within a POS program I have written in VB.net 2005, for touch screen computers I have it set to 'always on top' so the user can move the cursor to different text boxes and type using the on-screen keyboard The keyboard launches via the mouseclick event for any text box If another form is launched, with the onscreen keyboard still visible, the
7
3137
by: ManWithNoName | last post by:
If you have a form with x input and two or more buttons, how do you control which button has preceding when the user hits the keyboard key "enter"? Currently it seems to be determined in a hierarchical manner. E.g. <form>
5
1688
by: MikeB | last post by:
I have a simple form that I'm using to learn something about HTML and JavaScript. Can I associate a button on the form with a keyboard key so that when the user presses the keyboard key the form thinks the button has been clicked? Background: I'm learning HTML and JavaScript. We did a simple JavaScript that had a button that would add the numbers in two input fields.
0
8375
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8290
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8707
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8482
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6161
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4294
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1593
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.