What key is enter?

Previous topic - Next topic

Sev

Hello, another question.

What key is "enter" in GLBasic?   Spacebar is key 57. e.g.-> IF KEY(57)

Thanks
Red Text

kanonet

Enter (or return) has the scan code number 28. At least the normal one, the enter key on the numpad has the number 156.

You can use the keycode tool to get all scan codes you want, just go to tool->keycodes or simply press alt+k.
Lenovo Thinkpad T430u: Intel i5-3317U, 8GB DDR3, NVidia GeForce 620M, Micron RealSSD C400 @Win7 x64

mentalthink

Sev in the help F1 you have all the relationships for the keys for all platforms...

You can use Scankey, but in the forum a Coleague did a library for the keys, my counsil it's use some variable better then only the number in example.

Code (glbasic) Select

static key_Space
key_Space=key(57)

if key_Space Do_Something 

//This Way it's better when you use a lot of keys in your code, can be difficult rebember all the keys you are using in your program...

Schranz0r

Code (glbasic) Select
STATIC Key_Space = 57

IF KEY(Key_Space) THEN PRINT "WOHOO", 10,10
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

spacefractal

for games, dont use "hardwired" keys. Uses with variable (as Schranz0r shown), so users can remap eventuelly later.

A typical "bug" is when the Z key is used for jump, but then German users cant uses that (due Z and Y are swapped)...

Here is the code im often uses to find keys (such as space, shift, pause etc):
Code (glbasic) Select


// inkey key
LOCAL INKEYED=-1

IF INKEYED=-1
IF INKEY=0
FOR i=1 TO 255
IF KEY(i)
INKEY=i
BREAK
ENDIF
NEXT
ELSE
LOCAL ok=0
FOR i=1 TO 255
ok=ok+KEY(i)
IF ok>0 THEN BREAK
NEXT
IF ok=0 THEN INKEY=0
ENDIF
ELSE
INKEY=INKEYED
ENDIF
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

Schranz0r

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard