Catching a key or string

Hello,
is there a way to catch a key (or string) and store it in a variable to be used later without using a textfield?

Thank you

A Property in a WIndow or in a Module or in App ?

Emile, unsure he understand the question.

Say I have a window open with different items in it and I want to get a character or a string without having to type it into a textfield but just to store it into a variable for future use. Can I do it or do I need to go always through a textfield or some other item?

For this, you could use KeyDown Events of the Window or the focussed Item.

I guessed I had to use something like that but, I confess, I don’t have a clear idea on how to do it

Just try it. It’s often the best way to learn new stuff. :slight_smile:

Add the KeyDown Event to your window. In the KeyDown Event, the key Object will tell you which key has been pressed down. I recommend to use the key.ASCII Value to determine the key.

Maybe just start with a simple MsgBox "ASCII Code: " + Str(key.ASCII) and see what happens. :slight_smile:

http://documentation.xojo.com/index.php/Window.KeyDown

Can you explain better what you are trying to achieve ?