Audacity  3.0.3
Functions
Keyboard.cpp File Reference
#include "Keyboard.h"
#include <wx/event.h>
Include dependency graph for Keyboard.cpp:

Go to the source code of this file.

Functions

NormalizedKeyString KeyEventToKeyString (const wxKeyEvent &event)
 

Function Documentation

◆ KeyEventToKeyString()

NormalizedKeyString KeyEventToKeyString ( const wxKeyEvent &  event)

Definition at line 83 of file Keyboard.cpp.

84 {
85  wxString newStr;
86 
87  long key = event.GetKeyCode();
88 
89  if (event.ControlDown())
90  newStr += wxT("Ctrl+");
91 
92  if (event.AltDown())
93  newStr += wxT("Alt+");
94 
95  if (event.ShiftDown())
96  newStr += wxT("Shift+");
97 
98 #if defined(__WXMAC__)
99  if (event.RawControlDown())
100  newStr += wxT("RawCtrl+");
101 #endif
102 
103  if (event.RawControlDown() && key >= 1 && key <= 26)
104  newStr += (wxChar)(64 + key);
105  else if (key >= 33 && key <= 255 && key != 127)
106  newStr += (wxChar)key;
107  else
108  {
109  switch(key)
110  {
111  case WXK_BACK:
112  newStr += wxT("Backspace");
113  break;
114  case WXK_DELETE:
115  newStr += wxT("Delete");
116  break;
117  case WXK_SPACE:
118  newStr += wxT("Space");
119  break;
120  case WXK_TAB:
121  newStr += wxT("Tab");
122  break;
123  case WXK_RETURN:
124  newStr += wxT("Return");
125  break;
126  case WXK_PAGEUP:
127  newStr += wxT("PageUp");
128  break;
129  case WXK_PAGEDOWN:
130  newStr += wxT("PageDown");
131  break;
132  case WXK_END:
133  newStr += wxT("End");
134  break;
135  case WXK_HOME:
136  newStr += wxT("Home");
137  break;
138  case WXK_LEFT:
139  newStr += wxT("Left");
140  break;
141  case WXK_UP:
142  newStr += wxT("Up");
143  break;
144  case WXK_RIGHT:
145  newStr += wxT("Right");
146  break;
147  case WXK_DOWN:
148  newStr += wxT("Down");
149  break;
150  case WXK_ESCAPE:
151  newStr += wxT("Escape");
152  break;
153  case WXK_INSERT:
154  newStr += wxT("Insert");
155  break;
156  case WXK_NUMPAD0:
157  newStr += wxT("NUMPAD0");
158  break;
159  case WXK_NUMPAD1:
160  newStr += wxT("NUMPAD1");
161  break;
162  case WXK_NUMPAD2:
163  newStr += wxT("NUMPAD2");
164  break;
165  case WXK_NUMPAD3:
166  newStr += wxT("NUMPAD3");
167  break;
168  case WXK_NUMPAD4:
169  newStr += wxT("NUMPAD4");
170  break;
171  case WXK_NUMPAD5:
172  newStr += wxT("NUMPAD5");
173  break;
174  case WXK_NUMPAD6:
175  newStr += wxT("NUMPAD6");
176  break;
177  case WXK_NUMPAD7:
178  newStr += wxT("NUMPAD7");
179  break;
180  case WXK_NUMPAD8:
181  newStr += wxT("NUMPAD8");
182  break;
183  case WXK_NUMPAD9:
184  newStr += wxT("NUMPAD9");
185  break;
186  case WXK_MULTIPLY:
187  newStr += wxT("*");
188  break;
189  case WXK_ADD:
190  newStr += wxT("+");
191  break;
192  case WXK_SUBTRACT:
193  newStr += wxT("-");
194  break;
195  case WXK_DECIMAL:
196  newStr += wxT(".");
197  break;
198  case WXK_DIVIDE:
199  newStr += wxT("/");
200  break;
201  case WXK_F1:
202  newStr += wxT("F1");
203  break;
204  case WXK_F2:
205  newStr += wxT("F2");
206  break;
207  case WXK_F3:
208  newStr += wxT("F3");
209  break;
210  case WXK_F4:
211  newStr += wxT("F4");
212  break;
213  case WXK_F5:
214  newStr += wxT("F5");
215  break;
216  case WXK_F6:
217  newStr += wxT("F6");
218  break;
219  case WXK_F7:
220  newStr += wxT("F7");
221  break;
222  case WXK_F8:
223  newStr += wxT("F8");
224  break;
225  case WXK_F9:
226  newStr += wxT("F9");
227  break;
228  case WXK_F10:
229  newStr += wxT("F10");
230  break;
231  case WXK_F11:
232  newStr += wxT("F11");
233  break;
234  case WXK_F12:
235  newStr += wxT("F12");
236  break;
237  case WXK_F13:
238  newStr += wxT("F13");
239  break;
240  case WXK_F14:
241  newStr += wxT("F14");
242  break;
243  case WXK_F15:
244  newStr += wxT("F15");
245  break;
246  case WXK_F16:
247  newStr += wxT("F16");
248  break;
249  case WXK_F17:
250  newStr += wxT("F17");
251  break;
252  case WXK_F18:
253  newStr += wxT("F18");
254  break;
255  case WXK_F19:
256  newStr += wxT("F19");
257  break;
258  case WXK_F20:
259  newStr += wxT("F20");
260  break;
261  case WXK_F21:
262  newStr += wxT("F21");
263  break;
264  case WXK_F22:
265  newStr += wxT("F22");
266  break;
267  case WXK_F23:
268  newStr += wxT("F23");
269  break;
270  case WXK_F24:
271  newStr += wxT("F24");
272  break;
273  case WXK_NUMPAD_ENTER:
274  newStr += wxT("NUMPAD_ENTER");
275  break;
276  case WXK_NUMPAD_F1:
277  newStr += wxT("NUMPAD_F1");
278  break;
279  case WXK_NUMPAD_F2:
280  newStr += wxT("NUMPAD_F2");
281  break;
282  case WXK_NUMPAD_F3:
283  newStr += wxT("NUMPAD_F3");
284  break;
285  case WXK_NUMPAD_F4:
286  newStr += wxT("NUMPAD_F4");
287  break;
288  case WXK_NUMPAD_HOME:
289  newStr += wxT("NUMPAD_HOME");
290  break;
291  case WXK_NUMPAD_LEFT:
292  newStr += wxT("NUMPAD_LEFT");
293  break;
294  case WXK_NUMPAD_UP:
295  newStr += wxT("NUMPAD_UP");
296  break;
297  case WXK_NUMPAD_RIGHT:
298  newStr += wxT("NUMPAD_RIGHT");
299  break;
300  case WXK_NUMPAD_DOWN:
301  newStr += wxT("NUMPAD_DOWN");
302  break;
303  case WXK_NUMPAD_PAGEUP:
304  newStr += wxT("NUMPAD_PAGEUP");
305  break;
306  case WXK_NUMPAD_PAGEDOWN:
307  newStr += wxT("NUMPAD_PAGEDOWN");
308  break;
309  case WXK_NUMPAD_END:
310  newStr += wxT("NUMPAD_END");
311  break;
312  case WXK_NUMPAD_BEGIN:
313  newStr += wxT("NUMPAD_HOME");
314  break;
315  case WXK_NUMPAD_INSERT:
316  newStr += wxT("NUMPAD_INSERT");
317  break;
318  case WXK_NUMPAD_DELETE:
319  newStr += wxT("NUMPAD_DELETE");
320  break;
321  case WXK_NUMPAD_EQUAL:
322  newStr += wxT("NUMPAD_EQUAL");
323  break;
324  case WXK_NUMPAD_MULTIPLY:
325  newStr += wxT("NUMPAD_MULTIPLY");
326  break;
327  case WXK_NUMPAD_ADD:
328  newStr += wxT("NUMPAD_ADD");
329  break;
330  case WXK_NUMPAD_SUBTRACT:
331  newStr += wxT("NUMPAD_SUBTRACT");
332  break;
333  case WXK_NUMPAD_DECIMAL:
334  newStr += wxT("NUMPAD_DECIMAL");
335  break;
336  case WXK_NUMPAD_DIVIDE:
337  newStr += wxT("NUMPAD_DIVIDE");
338  break;
339  default:
340  return {}; // Don't do anything if we don't recognize the key
341  }
342  }
343 
344  return NormalizedKeyString{ newStr };
345 }

References key.

Referenced by CommandManager::FilterKeyEvent(), KeyConfigPrefs::OnFilterKeyDown(), and KeyConfigPrefs::OnHotkeyKeyDown().

Here is the caller graph for this function:
NormalizedKeyString
Definition: Keyboard.h:24
key
static const AudacityProject::AttachedObjects::RegisteredFactory key
Definition: CommandManager.cpp:201