mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-03 04:40:50 +03:00
soto: whitelist non-character keys
Inverting from an ongoing blacklist to a whitelist of a few functional keys.
This commit is contained in:
parent
3e1f3dca6e
commit
dee0312784
@ -22,12 +22,13 @@ export class Input extends Component {
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
let ignoredKeys = ["Meta", "Alt", "Control", "Escape", "Shift",
|
||||
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8",
|
||||
"F9", "F10", "F11", "F12", "Backspace", "Unidentified",
|
||||
"Delete", "Insert", "Home", "PageUp", "PageDown", "End",
|
||||
"Dead", "CapsLock"
|
||||
];
|
||||
let allowedKeys = [
|
||||
"Enter", "Backspace", "ArrowLeft", "ArrowRight", "Tab"
|
||||
];
|
||||
|
||||
if ((e.key.length > 1) && (!(allowedKeys.includes(e.key)))) {
|
||||
return;
|
||||
}
|
||||
|
||||
// submit on enter
|
||||
if (e.key === "Enter") {
|
||||
@ -63,7 +64,7 @@ export class Input extends Component {
|
||||
}
|
||||
|
||||
// capture and transmit most characters
|
||||
else if (ignoredKeys.indexOf(e.key) === -1) {
|
||||
else {
|
||||
store.doEdit({ ins: { cha: e.key, at: this.props.cursor } });
|
||||
store.setState({ cursor: this.props.cursor + 1 });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user