import FilledInput from '@material-ui/core/FilledInput'; import FormControl from '@material-ui/core/FormControl'; import InputLabel from '@material-ui/core/InputLabel'; import { useEffect, useRef, useState } from 'react'; import { v4 as uuid } from 'uuid'; function Keybind(props: { keyName: string; onClick?: () => any; }) { return {props.keyName}; } var keyBlacklist = [ 'Shift', 'Control', 'Alt', 'Meta', ]; var keyMap = { ' ': 'Space', }; export default function KeybindSelector(props: { label: string; value: string[]; onChange?: (newValue: string[]) => any; }) { var [inputID, _setInputID] = useState(uuid()); function KeybindSelectorInner() { return
{props.value.map(s => { props.onChange && props.onChange(props.value.filter(v => v != s)); }} /> )}
; } return { e.preventDefault(); var key = e.key; if (key in keyMap) key = keyMap[key]; if (keyBlacklist.includes(key)) return; var newArr = Array.from(props.value); if (!newArr.includes(key)) newArr.push(key); props.onChange(newArr); }} > {props.label} } /> ; }