回答編集履歴
3
ソリューションをGitHubに登録したので追記
test
CHANGED
@@ -28,6 +28,8 @@
|
|
28
28
|
|
29
29
|
|
30
30
|
|
31
|
+
2020/03/26 20:15 [ぎっとはぶのれぽじとり](https://github.com/lensouko/BlazorApp248757)に追加しました
|
32
|
+
|
31
33
|
|
32
34
|
|
33
35
|
Index.razor
|
2
キーイベントのdown・up・press全部確認するようにしました。チェックキーをTabにしました
test
CHANGED
@@ -18,6 +18,18 @@
|
|
18
18
|
|
19
19
|
|
20
20
|
|
21
|
+
2020/03/25 19:53
|
22
|
+
|
23
|
+
キーイベントをdown・up・press全部入れてログをまとめました
|
24
|
+
|
25
|
+
質問文通りにtextareaの文字列にtabを追加するようにしました
|
26
|
+
|
27
|
+
カーソル位置などは考慮していません
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
21
33
|
Index.razor
|
22
34
|
|
23
35
|
```C#
|
@@ -46,39 +58,37 @@
|
|
46
58
|
|
47
59
|
<p>
|
48
60
|
|
49
|
-
onkeydownのぱてぃ~ん<br />
|
50
|
-
|
51
|
-
<span style="color:red;">@msg
|
61
|
+
<span style="color:red;">@msg</span>
|
52
62
|
|
53
63
|
</p>
|
54
64
|
|
55
|
-
|
56
|
-
|
57
|
-
<textarea @bind="txtareadown" @onkeydown="inputDown" @onkeydown:preventDefault="isPrEvDefdown"></textarea>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
65
|
<p>
|
62
66
|
|
67
|
+
<textarea @bind="txtarea"
|
68
|
+
|
69
|
+
@onkeydown="inputDown"
|
70
|
+
|
71
|
+
@onkeydown:preventDefault="isPrEvDefdown"
|
72
|
+
|
73
|
+
@onkeyup="inputUp"
|
74
|
+
|
75
|
+
@onkeyup:preventDefault="isPrEvDefup"
|
76
|
+
|
63
|
-
onkeypress
|
77
|
+
@onkeypress="inputPress"
|
64
|
-
|
78
|
+
|
65
|
-
|
79
|
+
@onkeypress:preventDefault="isPrEvDefpress"></textarea>
|
66
80
|
|
67
81
|
</p>
|
68
82
|
|
69
83
|
|
70
84
|
|
71
|
-
<textarea @bind="txtareapress" @onkeypress="inputPress" @onkeypress:preventDefault="isPrEvDefpress"></textarea>
|
72
|
-
|
73
|
-
|
74
|
-
|
75
85
|
<p>
|
76
86
|
|
77
|
-
|
87
|
+
きーログ
|
78
88
|
|
79
89
|
<div style="height:200px;overflow-y:scroll;">
|
80
90
|
|
81
|
-
@foreach (var k in
|
91
|
+
@foreach (var k in Log)
|
82
92
|
|
83
93
|
{
|
84
94
|
|
@@ -92,116 +102,110 @@
|
|
92
102
|
|
93
103
|
|
94
104
|
|
95
|
-
<p>
|
96
|
-
|
97
|
-
|
105
|
+
@code
|
106
|
+
|
98
|
-
|
107
|
+
{
|
108
|
+
|
109
|
+
|
110
|
+
|
99
|
-
|
111
|
+
List<string> Log { get; set; } = new List<string>();
|
112
|
+
|
113
|
+
|
114
|
+
|
100
|
-
|
115
|
+
string txtarea { get; set; } = string.Empty;
|
116
|
+
|
117
|
+
string msg { get; set; } = string.Empty;
|
118
|
+
|
119
|
+
|
120
|
+
|
121
|
+
bool isPrEvDefdown { get; set; } = false;
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
private void inputDown(KeyboardEventArgs e)
|
126
|
+
|
127
|
+
{
|
128
|
+
|
129
|
+
isPrEvDefdown = IsKey(e, "Tab");
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
bool isPrEvDefpress { get; set; } = false;
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
private void inputPress(KeyboardEventArgs e)
|
140
|
+
|
141
|
+
{
|
142
|
+
|
143
|
+
isPrEvDefpress = IsKey(e, "Tab");
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
bool isPrEvDefup { get; set; } = false;
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
private void inputUp(KeyboardEventArgs e)
|
156
|
+
|
157
|
+
{
|
158
|
+
|
159
|
+
isPrEvDefup = IsKey(e, "Tab");
|
160
|
+
|
161
|
+
}
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
private bool IsKey(KeyboardEventArgs e,string chkKey, [System.Runtime.CompilerServices.CallerMemberName] string member = "")
|
166
|
+
|
167
|
+
{
|
168
|
+
|
169
|
+
Log.Add($"{DateTime.Now.ToString("hh:mm:ss.fff")}:[{member}]Key({e.Key})Code({e.Code})");
|
170
|
+
|
101
|
-
|
171
|
+
if (e.Key == "Tab")
|
102
172
|
|
103
173
|
{
|
104
174
|
|
105
|
-
|
175
|
+
msg = "たぶ!!";
|
176
|
+
|
177
|
+
txtarea = $"\t{txtarea}";
|
178
|
+
|
179
|
+
return true;
|
106
180
|
|
107
181
|
}
|
108
182
|
|
109
|
-
</div>
|
110
|
-
|
111
|
-
</p>
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
183
|
+
else
|
116
|
-
|
117
|
-
{
|
118
|
-
|
119
|
-
List<string> KeyLog { get; set; } = new List<string>();
|
120
|
-
|
121
|
-
List<string> CodeLog { get; set; } = new List<string>();
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
string txtareadown { get; set; } = string.Empty;
|
126
|
-
|
127
|
-
string msgdown { get; set; } = string.Empty;
|
128
|
-
|
129
|
-
bool isPrEvDefdown { get; set; } = false;
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
private void inputDown(KeyboardEventArgs e)
|
134
|
-
|
135
|
-
{
|
136
|
-
|
137
|
-
KeyLog.Add(e.Key);
|
138
|
-
|
139
|
-
CodeLog.Add(e.Code);
|
140
|
-
|
141
|
-
if (e.Key == "Enter")
|
142
184
|
|
143
185
|
{
|
144
186
|
|
145
|
-
msg
|
187
|
+
msg = string.Empty;
|
146
|
-
|
188
|
+
|
147
|
-
|
189
|
+
return false;
|
148
190
|
|
149
191
|
}
|
150
192
|
|
151
|
-
else
|
152
|
-
|
153
|
-
{
|
154
|
-
|
155
|
-
msgdown = string.Empty;
|
156
|
-
|
157
|
-
isPrEvDefdown = false;
|
158
|
-
|
159
|
-
|
193
|
+
}
|
160
|
-
|
161
|
-
|
194
|
+
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
195
|
+
|
166
|
-
|
167
|
-
string msgpress { get; set; } = string.Empty;
|
168
|
-
|
169
|
-
bool isPrEvDefpress { get; set; } = false;
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
private void inputPress(KeyboardEventArgs e)
|
174
|
-
|
175
|
-
{
|
176
|
-
|
177
|
-
KeyLog.Add(e.Key);
|
178
|
-
|
179
|
-
CodeLog.Add(e.Code);
|
180
|
-
|
181
|
-
if (e.Key == "Enter")
|
182
|
-
|
183
|
-
{
|
184
|
-
|
185
|
-
msgpress = "エンターはダメよ!";
|
186
|
-
|
187
|
-
isPrEvDefpress = true;
|
188
|
-
|
189
|
-
}
|
190
|
-
|
191
|
-
else
|
192
|
-
|
193
|
-
{
|
194
|
-
|
195
|
-
msgpress = string.Empty;
|
196
|
-
|
197
|
-
isPrEvDefpress = false;
|
198
|
-
|
199
|
-
}
|
200
|
-
|
201
|
-
}
|
202
196
|
|
203
197
|
}
|
204
198
|
|
205
|
-
|
206
|
-
|
207
199
|
```
|
200
|
+
|
201
|
+
|
202
|
+
|
203
|
+
動作確認ブラウザ
|
204
|
+
|
205
|
+
EdgeHTMLのEdge
|
206
|
+
|
207
|
+
ChroniumのEdge
|
208
|
+
|
209
|
+
Chrome
|
210
|
+
|
211
|
+
Firefox
|
1
StateHasChangedとmin-height:200px;いらんかったわ
test
CHANGED
@@ -76,7 +76,7 @@
|
|
76
76
|
|
77
77
|
e.Keyのログ
|
78
78
|
|
79
|
-
<div style="height:200px;
|
79
|
+
<div style="height:200px;overflow-y:scroll;">
|
80
80
|
|
81
81
|
@foreach (var k in KeyLog)
|
82
82
|
|
@@ -96,7 +96,7 @@
|
|
96
96
|
|
97
97
|
e.Codeのログ
|
98
98
|
|
99
|
-
<div style="height:200px;
|
99
|
+
<div style="height:200px;overflow-y:scroll;">
|
100
100
|
|
101
101
|
@foreach (var c in CodeLog)
|
102
102
|
|
@@ -116,8 +116,6 @@
|
|
116
116
|
|
117
117
|
{
|
118
118
|
|
119
|
-
|
120
|
-
|
121
119
|
List<string> KeyLog { get; set; } = new List<string>();
|
122
120
|
|
123
121
|
List<string> CodeLog { get; set; } = new List<string>();
|
@@ -126,12 +124,8 @@
|
|
126
124
|
|
127
125
|
string txtareadown { get; set; } = string.Empty;
|
128
126
|
|
129
|
-
|
130
|
-
|
131
127
|
string msgdown { get; set; } = string.Empty;
|
132
128
|
|
133
|
-
|
134
|
-
|
135
129
|
bool isPrEvDefdown { get; set; } = false;
|
136
130
|
|
137
131
|
|
@@ -164,22 +158,14 @@
|
|
164
158
|
|
165
159
|
}
|
166
160
|
|
167
|
-
this.StateHasChanged();
|
168
|
-
|
169
161
|
}
|
170
162
|
|
171
163
|
|
172
164
|
|
173
|
-
|
174
|
-
|
175
165
|
string txtareapress { get; set; } = string.Empty;
|
176
166
|
|
177
|
-
|
178
|
-
|
179
167
|
string msgpress { get; set; } = string.Empty;
|
180
168
|
|
181
|
-
|
182
|
-
|
183
169
|
bool isPrEvDefpress { get; set; } = false;
|
184
170
|
|
185
171
|
|
@@ -212,12 +198,10 @@
|
|
212
198
|
|
213
199
|
}
|
214
200
|
|
215
|
-
this.StateHasChanged();
|
216
|
-
|
217
201
|
}
|
218
202
|
|
219
|
-
|
220
|
-
|
221
203
|
}
|
222
204
|
|
205
|
+
|
206
|
+
|
223
207
|
```
|