morethanwords
3 years ago
18 changed files with 113 additions and 56 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
/* |
||||
* https://github.com/morethanwords/tweb
|
||||
* Copyright (C) 2019-2021 Eduard Kuzmenko |
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||
*/ |
||||
|
||||
export default function getKeyFromEvent(e: KeyboardEvent) { |
||||
let key = e.key; |
||||
if(!key) { |
||||
key = e.code; |
||||
if(key.startsWith('Key')) { |
||||
key = e.code.slice(3); |
||||
|
||||
if(!e.shiftKey && key.length < 2) { |
||||
key = key.toLowerCase(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
return key; |
||||
} |
@ -0,0 +1,12 @@
@@ -0,0 +1,12 @@
|
||||
/* |
||||
* https://github.com/morethanwords/tweb
|
||||
* Copyright (C) 2019-2021 Eduard Kuzmenko |
||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
||||
*/ |
||||
|
||||
import getKeyFromEvent from "./getKeyFromEvent"; |
||||
import { capitalizeFirstLetter } from "../string"; |
||||
|
||||
export default function getKeyFromEventCaseInsensitive(e: KeyboardEvent) { |
||||
return capitalizeFirstLetter(getKeyFromEvent(e)); |
||||
} |
Loading…
Reference in new issue