Solved

Convert (var Key: Word) to ASCII Character

Posted on 2009-05-08
10
4,630 Views
Last Modified: 2012-05-06
FormKeyDown(Sender: TObject; var Key: Word;  Shift: TShiftState);

There has to be an easy way to  convert (Key) to the ASCII equivalent?
Something like;
  var
    s: String;
   
    s := WordToStr(Key);

Brain Dead........

0
Comment
Question by:SurferJoe
10 Comments
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 425 total points
Comment Utility
Char(Key), perhaps?
0
 
LVL 26

Accepted Solution

by:
EddieShipman earned 425 total points
Comment Utility
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if ssShift in Shift then
    ShowMessage(Char(Key))
  else
    ShowMessage(LowerCase(Char(Key)));
end;
0
 
LVL 5

Assisted Solution

by:louislietaer
louislietaer earned 25 total points
Comment Utility
No

Chr(Key) will give a char (see also ord() function)

Char will cast the word, I will not recommend.

you could use it like that

if (chr(Key)='a') or (chr(key)='A') then
begin
  ...
end
0
 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
Comment Utility
this is a virtual key you are getting
check the VK_ constants in the windows unit

ciuly created a small unit to create such a unit once for me:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_23823866.html

that time it was for the messages.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
Comment Utility
>> Never did get any of this to meet my needs, please close question.

you haven't even posted a remark

this is not just ask a question and wait for an answer
if you see you aren't getting anywhere then post some more info
or react on the comments
0
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 425 total points
Comment Utility
I agree, you were given several correct answers to your question on how to convert the word in a KeyDown to a character.

You must select one or more as the answer, dude!
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
modus, why did you select an answer?
0
 
LVL 4

Author Comment

by:SurferJoe
Comment Utility
I selected an answer as I  could not bear the complaints.
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
It would have been easier to tell us what about the posted solutions didn't work for you than to try to delete the question without an explanation. As I said earlier, you were given several correct answers to your question and you were expected to select one or more.

If you'd been more upfront with us, there would have not been any complaints.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now