×

Gamemaker GM插件扩展脚本 玉米原创

【脚本】返回按键名的字符串

Mage松仁玉米 Mage松仁玉米 发表于2016-02-05 03:10:48 浏览5716 评论1

1人参与发表评论

关于在GM上有一个问题,就是按键名,有的时候,需要玩家设置按键,然后来显示玩家设定的按键是什么。在GM里,是用键位码来表示按键的,那么这个脚本,就是给定一个键位码,然后返回这个键的名称字符串用的。

其实非常简单的玩意,就是switch里面套了一大堆东西,没什么技术含量,需要的拿走就行。

贴下代码。

//keyboard_get_name(key)
switch(argument0)
{
case 27:return"ESC"
case 112:return"F1"
case 113:return"F2"
case 114:return"F3"
case 115:return"F4"
case 116:return"F5"
case 117:return"F6"
case 118:return"F7"
case 119:return"F8"
case 120:return"F9"
case 121:return"F10"
case 122:return"F11"
case 123:return"F12"
case 192:return"`"
case 48:return"0"
case 49:return"1"
case 50:return"2"
case 51:return"3"
case 52:return"4"
case 53:return"5"
case 54:return"6"
case 55:return"7"
case 56:return"8"
case 57:return"9"
case 189:return"-"
case 187:return"="
case 8:return"BACKSPACE"
case 65:return"A"
case 66:return"B"
case 67:return"C"
case 68:return"D"
case 69:return"E"
case 70:return"F"
case 71:return"G"
case 72:return"H"
case 73:return"I"
case 74:return"J"
case 75:return"K"
case 76:return"L"
case 77:return"M"
case 78:return"N"
case 79:return"O"
case 80:return"P"
case 81:return"Q"
case 82:return"R"
case 83:return"S"
case 84:return"T"
case 85:return"U"
case 86:return"V"
case 87:return"W"
case 88:return"X"
case 89:return"Y"
case 90:return"Z"
case 20:return"CAPS LOCK"
case 16:return"SHIFT"
case 17:return"CTRL"
case 91:return"WIN"
case 18:return"ALT"
case 32:return"SPACE"
case 219:return"["
case 221:return"]"
case 186:return";"
case 222:return"'"
case 220:return"\"
case 188:return","
case 190:return"."
case 191:return"/"
case 13:return"ENTER"
case 93:return"MNUE"
case 145:return"SCROLL LOCK"
case 19:return"PAUSE BREAK"
case 45:return"INSERT"
case 36:return"HOME"
case 33:return"PAGE UP"
case 46:return"DELETE"
case 35:return"END"
case 34:return"PAGE DOWN"
case 37:return"LEFT"
case 38:return"UP"
case 39:return"RIGHT"
case 40:return"DOWN"
case 144:return"NUM LOCK"
case 111:return"NUM /"
case 106:return"NUM *"
case 109:return"NUM -"
case 96:return"NUM 0"
case 97:return"NUM 1"
case 98:return"NUM 2"
case 99:return"NUM 3"
case 100:return"NUM 4"
case 101:return"NUM 5"
case 102:return"NUM 6"
case 103:return"NUM 7"
case 104:return"NUM 8"
case 105:return"NUM 9"
case 110:return"NUM ."
case 107:return"NUM +"
case -1:return"NONE"
}

给个使用说明吧~

show_message(keyboard_get_name(vk_space))

这段代码,会返回空格键的名字,也就是字符串”SPACE”

↓↓支持小站发展,点一点小广告,么么哒(づ ̄ 3 ̄)づ↓↓

BB点儿啥

访客
魔方12139 魔方121392019-08-31 12:48:44 · 回复 做过类似的,获取颜色名称