mirror of
				https://github.com/langgenius/dify.git
				synced 2025-10-31 02:42:59 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			766 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			766 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| export const isMac = () => {
 | |
|   return navigator.userAgent.toUpperCase().includes('MAC')
 | |
| }
 | |
| 
 | |
| const specialKeysNameMap: Record<string, string | undefined> = {
 | |
|   ctrl: '⌘',
 | |
|   alt: '⌥',
 | |
|   shift: '⇧',
 | |
| }
 | |
| 
 | |
| export const getKeyboardKeyNameBySystem = (key: string) => {
 | |
|   if (isMac())
 | |
|     return specialKeysNameMap[key] || key
 | |
| 
 | |
|   return key
 | |
| }
 | |
| 
 | |
| const specialKeysCodeMap: Record<string, string | undefined> = {
 | |
|   ctrl: 'meta',
 | |
| }
 | |
| 
 | |
| export const getKeyboardKeyCodeBySystem = (key: string) => {
 | |
|   if (isMac())
 | |
|     return specialKeysCodeMap[key] || key
 | |
| 
 | |
|   return key
 | |
| }
 | |
| 
 | |
| export const isEventTargetInputArea = (target: HTMLElement) => {
 | |
|   if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')
 | |
|     return true
 | |
| 
 | |
|   if (target.contentEditable === 'true')
 | |
|     return true
 | |
| }
 | 
