add keyboard shortcuts for quicker input

This commit is contained in:
Jakob Ketterl 2021-02-27 22:30:48 +01:00
parent c389d3b619
commit 71acad3b4f

View File

@ -1,4 +1,11 @@
$.fn.frequencyInput = function() { $.fn.frequencyInput = function() {
var suffixes = {
"K": 3,
"M": 6,
"G": 9,
"T": 12
};
this.each(function(){ this.each(function(){
var $group = $(this); var $group = $(this);
var currentExponent = 0; var currentExponent = 0;
@ -11,6 +18,14 @@ $.fn.frequencyInput = function() {
currentExponent = newExponent; currentExponent = newExponent;
}; };
$input.on('keydown', function(e) {
var c = String.fromCharCode(e.which);
if (c in suffixes) {
currentExponent = suffixes[c];
$exponent.val(suffixes[c]);
}
});
$exponent = $group.find('select.frequency-exponent'); $exponent = $group.find('select.frequency-exponent');
$exponent.on('change', setExponent); $exponent.on('change', setExponent);