feat(new-tool): keycode info
This commit is contained in:
		
							parent
							
								
									4a5734d4a3
								
							
						
					
					
						commit
						c934c4e50c
					
				| @ -1,6 +1,7 @@ | |||||||
| import { tool as base64FileConverter } from './base64-file-converter'; | import { tool as base64FileConverter } from './base64-file-converter'; | ||||||
| import { tool as base64StringConverter } from './base64-string-converter'; | import { tool as base64StringConverter } from './base64-string-converter'; | ||||||
| import { tool as basicAuthGenerator } from './basic-auth-generator'; | import { tool as basicAuthGenerator } from './basic-auth-generator'; | ||||||
|  | import { tool as keycodeInfo } from './keycode-info'; | ||||||
| import { tool as jsonMinify } from './json-minify'; | import { tool as jsonMinify } from './json-minify'; | ||||||
| import { tool as bcrypt } from './bcrypt'; | import { tool as bcrypt } from './bcrypt'; | ||||||
| import { tool as bip39 } from './bip39-generator'; | import { tool as bip39 } from './bip39-generator'; | ||||||
| @ -67,6 +68,7 @@ export const toolsByCategory: ToolCategory[] = [ | |||||||
|       otpCodeGeneratorAndValidator, |       otpCodeGeneratorAndValidator, | ||||||
|       mimeTypes, |       mimeTypes, | ||||||
|       jwtParser, |       jwtParser, | ||||||
|  |       keycodeInfo, | ||||||
|     ], |     ], | ||||||
|   }, |   }, | ||||||
|   { |   { | ||||||
|  | |||||||
							
								
								
									
										26
									
								
								src/tools/keycode-info/index.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								src/tools/keycode-info/index.ts
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | |||||||
|  | import { Keyboard } from '@vicons/tabler'; | ||||||
|  | import { defineTool } from '../tool'; | ||||||
|  | 
 | ||||||
|  | export const tool = defineTool({ | ||||||
|  |   name: 'Keycode info', | ||||||
|  |   path: '/keycode-info', | ||||||
|  |   description: 'Find the javascript keycode, code, location and modifiers of any pressed key.', | ||||||
|  |   keywords: [ | ||||||
|  |     'keycode', | ||||||
|  |     'info', | ||||||
|  |     'code', | ||||||
|  |     'javascript', | ||||||
|  |     'event', | ||||||
|  |     'keycodes', | ||||||
|  |     'which', | ||||||
|  |     'keyboard', | ||||||
|  |     'press', | ||||||
|  |     'modifier', | ||||||
|  |     'alt', | ||||||
|  |     'ctrl', | ||||||
|  |     'meta', | ||||||
|  |     'shift', | ||||||
|  |   ], | ||||||
|  |   component: () => import('./keycode-info.vue'), | ||||||
|  |   icon: Keyboard, | ||||||
|  | }); | ||||||
							
								
								
									
										67
									
								
								src/tools/keycode-info/keycode-info.vue
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								src/tools/keycode-info/keycode-info.vue
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,67 @@ | |||||||
|  | <template> | ||||||
|  |   <div> | ||||||
|  |     <n-card style="text-align: center; padding: 40px 0; margin-bottom: 26px"> | ||||||
|  |       <n-h2 v-if="event">{{ event.key }}</n-h2> | ||||||
|  |       <n-text strong depth="3">Press the key on your keyboard you want to now stuff</n-text> | ||||||
|  |     </n-card> | ||||||
|  | 
 | ||||||
|  |     <n-input-group v-for="({ label, value, placeholder }, i) of fields" :key="i" style="margin-bottom: 5px"> | ||||||
|  |       <n-input-group-label style="flex: 0 0 150px"> {{ label }} </n-input-group-label> | ||||||
|  |       <input-copyable :value="value" readonly :placeholder="placeholder" /> | ||||||
|  |     </n-input-group> | ||||||
|  |   </div> | ||||||
|  | </template> | ||||||
|  | 
 | ||||||
|  | <script setup lang="ts"> | ||||||
|  | import { useEventListener } from '@vueuse/core'; | ||||||
|  | import { computed, ref } from 'vue'; | ||||||
|  | import InputCopyable from '../../components/InputCopyable.vue'; | ||||||
|  | 
 | ||||||
|  | const event = ref<KeyboardEvent>(); | ||||||
|  | 
 | ||||||
|  | useEventListener(document, 'keydown', (e) => { | ||||||
|  |   event.value = e; | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | const fields = computed(() => { | ||||||
|  |   if (!event.value) return []; | ||||||
|  | 
 | ||||||
|  |   return [ | ||||||
|  |     { | ||||||
|  |       label: 'Key :', | ||||||
|  |       value: event.value.key, | ||||||
|  |       placeholder: 'Key name...', | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       label: 'Keycode :', | ||||||
|  |       value: String(event.value.keyCode), | ||||||
|  |       placeholder: 'Keycode...', | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       label: 'Code :', | ||||||
|  |       value: event.value.code, | ||||||
|  |       placeholder: 'Code...', | ||||||
|  |     }, | ||||||
|  |     { | ||||||
|  |       label: 'Location :', | ||||||
|  |       value: String(event.value.location), | ||||||
|  |       placeholder: 'Code...', | ||||||
|  |     }, | ||||||
|  | 
 | ||||||
|  |     { | ||||||
|  |       label: 'Modifiers :', | ||||||
|  |       value: [ | ||||||
|  |         event.value.metaKey && 'Meta', | ||||||
|  |         event.value.shiftKey && 'Shift', | ||||||
|  |         event.value.ctrlKey && 'Ctrl', | ||||||
|  |         event.value.altKey && 'Alt', | ||||||
|  |       ] | ||||||
|  |         .filter(Boolean) | ||||||
|  |         .join(' + '), | ||||||
|  |       placeholder: 'None', | ||||||
|  |     }, | ||||||
|  |   ]; | ||||||
|  | }); | ||||||
|  | </script> | ||||||
|  | 
 | ||||||
|  | <style lang="less" scoped></style> | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user