• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

SOLVED How do I make GMS2 recognize a comma?

M

Mobie

Guest
As you might know, I use GMS2 to make educational games and I am trying to make one where using the comma is important. I have been trying various lines of code that I know (sort of) to make GMS2 recognize when a comma is pressed and have had no success. I've pasted my failed attempts below. I think the ASCII for a comma is 44. The "room_goto(rm_menu)" was just something stuck in there to see if it worked.

Can you offer any insight?

Gamemaker didn't react to any of these when I pressed the comma.

not this
if keyboard_check(ord(44))room_goto(rm_menu);

or this
if keyboard_check(ord(","))room_goto(rm_menu);

or this
if(keyboard_key == 44)room_goto(rm_menu);

or this
if keyboard_check(44)room_goto(rm_menu);

or this
if(keyboard_key == ord(44))room_goto(rm_menu);

This one fired instantly no matter which key was pressed
if(keyboard_key == ",")room_goto(rm_menu);
 
Last edited by a moderator:

TsukaYuriko

☄️
Forum Staff
Moderator
The comma is a character, not specifically a key. ASCII character codes have nothing to do with key codes, the two just happen to match partially (e. g. letters). Which key produces a comma character depends on the keyboard layout in use.

Try checking if keyboard_lastchar is a comma.
 
M

Mobie

Guest
The comma is a character, not specifically a key. ASCII character codes have nothing to do with key codes, the two just happen to match partially (e. g. letters). Which key produces a comma character depends on the keyboard layout in use.

Try checking if keyboard_lastchar is a comma.
It worked!! Thanks so much TY!

if(keyboard_lastchar == ",")room_goto(rm_menu);
 

YellowAfterlife

ᴏɴʟɪɴᴇ ᴍᴜʟᴛɪᴘʟᴀʏᴇʀ
Forum Staff
Moderator
You would want keyboard_check(188), I wrote a blog post on the matter of key codes
 
M

Mobie

Guest
You would want keyboard_check(188), I wrote a blog post on the matter of key codes
Very good! Your help is greatly appreciated YA!
 
Top