Oh keystrokes, I thought with button you meant literally the button element which panels can have.
To check which key the user pressed last use 'key_lastpressed'. See the manual for more info (Engine Variables -> Input/output -> Keyboard -> key_lastpressed).
Also I want to save the data that while a panel appears and users click a key to close this panel screen and I want to save time these two between events (panel appears time --> keystroke to close panel time).
, there are a few ways. First you will have to know when the panel is shown. Most easiest is to just check in a while loop (like the one from your Main function) if the panel is shown, and when shown begin a timer till the panel is closed. When the panel is closed you can save the timer variable somewhere. Example:
function Main () {
....
var timer = 0;
while (1) {
...
if (is(myPanel, SHOW)) {
timer += time_step / 16; //add 1 point per sec
}
else { //panel is not shown?
if (timer > 0) { //timer was started and panel is closed?
....save timer variable somewhere...
timer = 0; //reset
}
}
wait(1);
}
}