键盘检测命令指南
适用于所有按键的高级 Minecraft 键盘事件检测!
命令概览
| 命令 |
功能 |
关键参数 |
iskeydown |
单键按下检测 |
<KeyAscii>, <keepStatic> |
matchgroup |
多键组合检测 |
<KeyAsciiList> |
iskeytapped |
瞬时多键组合检测 |
<KeyAsciiList> |
flush |
重置子命令 iskeydown 的按键状态 |
None |
1. 单键检测:/keyboarddetector iskeydown
功能
检测特定键盘按键的实时按下状态。
命令语法
/keyboarddetector iskeydown <PlayerID> <KeyAscii>
| 参数 |
描述 |
示例值 |
<PlayerID> |
目标玩家选择器 |
@p, @a[limit=1], @e[type=player,limit=1] |
<KeyAscii> |
要检测的按键 ASCII 码 |
49 |
<keepStatic> |
持久状态模式 (true/false) |
true, false |
使用示例
标准模式:
/keyboarddetector iskeydown @p 49 false
检测按键 '1' 的长按。
持久模式:
/keyboarddetector iskeydown @p 49 true
如果目标玩家按下了 '1' 键,命令方块将返回 true 并持续激活红石信号 (直到执行 /keyboarddetector flush)。
命令方块行为
| 模式 |
行为 |
标准模式 (keepStatic=false) |
• 当所有按键同时按下时激活信号 • 任一按键松开时立即停用信号 |
持久模式 (keepStatic=true) |
• 在首次成功检测时锁定信号。 • 按键松开后保持激活状态。 • 需要手动刷新以重置 |
2. 按键组合检测:/keyboarddetector matchgroup
功能
检测多个按键的同时按下。(独立按键处理)
命令语法
/keyboarddetector matchgroup <PlayerID> <KeyAsciiList> <keepStatic>
参数
| 参数 |
描述 |
示例值 |
<PlayerID> |
目标玩家选择器 |
@p, @a[limit=1], @e[type=player,limit=1] |
<KeyAscii> |
逗号分隔的 ASCII 码 |
49,50,51 |
使用示例
/keyboarddetector matchgroup @p 49,50,51
检测按键 '1', '2', '3' 的同时按下。
命令方块行为
- 在循环命令方块中:
- ? 按键按下:返回 true 并激活红石信号
- ⚪ 按键松开:返回 false 并停用红石信号
3. 瞬时按键组合检测:/keyboarddetector iskeytapped
功能
仅检测多个按键被按下的瞬间。(独立按键处理)。
命令语法
/keyboarddetector iskeytapped <PlayerID> <KeyAsciiList> <keepStatic>
参数
| 参数 |
描述 |
示例值 |
<PlayerID> |
目标玩家选择器 |
@p, @a[limit=1], @e[type=player,limit=1] |
<KeyAscii> |
逗号分隔的 ASCII 码 |
49,50,51 |
使用示例
/keyboarddetector iskeytapped @p 49,50,51
检测按键 '1', '2', '3' 被按下的瞬间。
命令方块行为
- 在循环命令方块中:
- ? 按键按下:仅在按键按下的瞬间返回 true 并激活红石信号。
- ⚪ 按键按住:返回 false 并停用红石信号。(与
/keyboarddetector matchgroup 不同)
- ⚪ 按键松开:返回 false 并停用红石信号
4. 状态重置命令:/keyboarddetector flush
功能
清除由 keepStatic=true 的 iskeydown 创建的持久按键状态
使用场景
- 激活持久模式:
/keyboarddetector iskeydown @p 49 true
-
按键按下后,信号保持激活
-
重置检测状态 (必须配合条件语句):
/keyboarddetector flush
效果
♻️ 重置所有检测状态
? 需要新的按键组合按下才能重新激活
注意
❗ 当超过 1 个命令方块正在执行 /keyboarddetector matchgroup 时,确保所有的 <AsciiList> 中不能包含任何重复的值。否则,只能触发其中一个按键事件。
❗ 不要在没有条件语句的情况下使用 /keyboarddetector flush。否则,所有检测子命令将不可用。
ASCII 按键参考表
| 按键 |
ASCII 码 |
按键 |
ASCII 码 |
| 数字键 |
|
字母键 |
|
| 0 |
48 |
A |
65 |
| 1 |
49 |
B |
66 |
| 2 |
50 |
C |
67 |
| 3 |
51 |
D |
68 |
| 4 |
52 |
E |
69 |
| 5 |
53 |
F |
70 |
| 6 |
54 |
G |
71 |
| 7 |
55 |
H |
72 |
| 8 |
56 |
I |
73 |
| 9 |
57 |
J |
74 |
|
|
K |
75 |
|
|
L |
76 |
|
|
M |
77 |
|
|
N |
78 |
|
|
O |
79 |
|
|
P |
80 |
|
|
Q |
81 |
|
|
R |
82 |
|
|
S |
83 |
|
|
T |
84 |
|
|
U |
85 |
|
|
V |
86 |
|
|
W |
87 |
|
|
X |
88 |
|
|
Y |
89 |
|
|
Z |
90 |
|
|
|
|
| 功能键 |
|
特殊键 |
|
| F1 |
112 |
Space(空格) |
32 |
| F2 |
113 |
Enter(回车) |
13 |
| F3 |
114 |
Esc(退出) |
27 |
| F4 |
115 |
Tab(制表符) |
9 |
| F5 |
116 |
Caps Lock(大写锁定) |
20 |
| F6 |
117 |
Shift(换档) |
16 |
| F7 |
118 |
Ctrl(控制) |
17 |
| F8 |
119 |
Alt(替代) |
18 |
| F9 |
120 |
Backspace(退格) |
8 |
| F10 |
121 |
Delete(删除) |
46 |
| F11 |
122 |
Insert(插入) |
45 |
| F12 |
123 |
Home(首页) |
36 |
|
|
End(结尾) |
35 |
|
|
Page Up(向上翻页) |
33 |
|
|
Page Down(向下翻页) |
34 |
|
|
Arrow Up(上箭头) |
38 |
|
|
Arrow Down(下箭头) |
40 |
|
|
Arrow Left(左箭头) |
37 |
|
|
Arrow Right(右箭头) |
39 |
备注:
- 小写字母:a=97, b=98 ... z=122
- 数字小键盘:0=96, 1=97 ... 9=105
- 区分大小写(A=65 vs a=97)
- 完整参考:ASCII 表
Keyboard Detector Command Guide
Advanced keyboard event detection in Minecraft for all keys!
Command Overview
| Command |
Functionality |
Key Parameters |
iskeydown |
Single key press detection |
<KeyAscii>, <keepStatic> |
matchgroup |
Multi-key combination detection |
<KeyAsciiList> |
iskeytapped |
Instant Multi-key combination detection |
<KeyAsciiList> |
flush |
Reset key states for subcommand iskeydown |
None |
1. Single Key Detection: /keyboarddetector iskeydown
Functionality
Detects real-time press state of a specific keyboard key.
Command Syntax
/keyboarddetector iskeydown <PlayerID> <KeyAscii>
| Parameter |
Description |
Example Values |
<PlayerID> |
Target player selector |
@p, @a[limit=1], @e[type=player,limit=1] |
<KeyAscii> |
ASCII code of the key to detect |
49 |
<keepStatic> |
Persistent state mode (true/false) |
true, false |
Usage Examples
Standard mode:
/keyboarddetector iskeydown @p 49 false
Detects long-press of key '1'.
Persistent mode:
/keyboarddetector iskeydown @p 49 true
If target player have pressed the '1' key, the command block will return true and activate redstone signal constantly (Until /keyboarddetector flush is executed).
Command Block Behavior
| Mode |
Behavior |
Standard Mode (keepStatic=false) |
• Activates signal when all keys are pressed simultaneously • Deactivates immediately when any key is released |
Persistent Mode (keepStatic=true) |
• Locks signal on first successful detection. • Maintains activation after keys are released. • Requires manual flush to reset |
2. Key Combination Detection: /keyboarddetector matchgroup
Functionality
Detects simultaneous pressing of multiple keys. (independent key processing)
Command Syntax
/keyboarddetector matchgroup <PlayerID> <KeyAsciiList> <keepStatic>
Parameters
| Parameter |
Description |
Example Values |
<PlayerID> |
Target player selector |
@p, @a[limit=1], @e[type=player,limit=1] |
<KeyAscii> |
Comma-separated ASCII codes |
49,50,51 |
Usage Examples
/keyboarddetector matchgroup @p 49,50,51
Detects simultaneous press of keys '1', '2', '3'.
Command Block Behavior
- In repeating command blocks:
- ? Key pressed: Returns true and activates redstone signal
- ⚪ Key released: Returns false and deactivates redstone signal
3.Instant Key Combination Detection: /keyboarddetector iskeytapped
Functionality
Detect solely the instant when the key is pressed for multiple keys. (independent key processing).
Command Syntax
/keyboarddetector iskeytapped <PlayerID> <KeyAsciiList> <keepStatic>
Parameters
| Parameter |
Description |
Example Values |
<PlayerID> |
Target player selector |
@p, @a[limit=1], @e[type=player,limit=1] |
<KeyAscii> |
Comma-separated ASCII codes |
49,50,51 |
Usage Examples
/keyboarddetector iskeytapped @p 49,50,51
Detects solely the instant when the key '1', '2', '3' are pressed.
Command Block Behavior
- In repeating command blocks:
- ? Key pressed: Returns true and activates redstone signal solely the instant when the key is pressed.
- ⚪ Key hold: Returns false and deactivates redstone signal. (Different from
/keyboarddetector matchgroup)
- ⚪ Key released: Returns false and deactivates redstone signal
4. State Reset Command: /keyboarddetector flush
Functionality
Clears persistent key states created by iskeydown with keepStatic=true
Usage Scenario
- Persistent mode activated:
/keyboarddetector iskeydown @p 49 true
-
After keys are pressed, signal stays active
-
Reset detection state (must with conditional statement):
/keyboarddetector flush
Effects
♻️ Resets all detection states
? Requires new key combination press to reactivate
Attention
❗ When more than 1 command blocks are exetuting /keyboarddetector matchgroup, make sure all <AsciiList> must not contain any duplicate values. Otherwise, only one of the key events can be triggered.
❗ Do not use /keyboarddetector flush without conditional statement. Otherwise, all subcommands for decection won't be available.
ASCII Key Reference Table
| Key |
ASCII Code |
Key |
ASCII Code |
| Numbers |
|
Letters |
|
| 0 |
48 |
A |
65 |
| 1 |
49 |
B |
66 |
| 2 |
50 |
C |
67 |
| 3 |
51 |
D |
68 |
| 4 |
52 |
E |
69 |
| 5 |
53 |
F |
70 |
| 6 |
54 |
G |
71 |
| 7 |
55 |
H |
72 |
| 8 |
56 |
I |
73 |
| 9 |
57 |
J |
74 |
|
|
K |
75 |
|
|
L |
76 |
|
|
M |
77 |
|
|
N |
78 |
|
|
O |
79 |
|
|
P |
80 |
|
|
Q |
81 |
|
|
R |
82 |
|
|
S |
83 |
|
|
T |
84 |
|
|
U |
85 |
|
|
V |
86 |
|
|
W |
87 |
|
|
X |
88 |
|
|
Y |
89 |
|
|
Z |
90 |
|
|
|
|
| Functions |
|
Special |
|
| F1 |
112 |
Space |
32 |
| F2 |
113 |
Enter |
13 |
| F3 |
114 |
Esc |
27 |
| F4 |
115 |
Tab |
9 |
| F5 |
116 |
Caps Lock |
20 |
| F6 |
117 |
Shift |
16 |
| F7 |
118 |
Ctrl |
17 |
| F8 |
119 |
Alt |
18 |
| F9 |
120 |
Backspace |
8 |
| F10 |
121 |
Delete |
46 |
| F11 |
122 |
Insert |
45 |
| F12 |
123 |
Home |
36 |
|
|
End |
35 |
|
|
Page Up |
33 |
|
|
Page Down |
34 |
|
|
Arrow Up |
38 |
|
|
Arrow Down |
40 |
|
|
Arrow Left |
37 |
|
|
Arrow Right |
39 |
Notes:
- Lowercase letters: a=97, b=98 ... z=122
- Numeric keypad: 0=96, 1=97 ... 9=105
- Case sensitive (A=65 vs a=97)
- Full reference: ASCII Table
评论 0
登录后参与评分
还没有评论,来抢沙发吧