Solved

Convert (var Key: Word) to ASCII Character

Posted on 2009-05-08
10
4,808 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:Greg Rowland
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 26

Assisted Solution

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

Accepted Solution

by:
EddieShipman earned 425 total points
ID: 24336075
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
ID: 24336272
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
ID: 24336407
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
 
LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
ID: 24908704
>> 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
ID: 24908870
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
ID: 24909241
modus, why did you select an answer?
0
 
LVL 4

Author Comment

by:Greg Rowland
ID: 24909371
I selected an answer as I  could not bear the complaints.
0
 
LVL 26

Expert Comment

by:EddieShipman
ID: 24909675
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 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