Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 1x | import { Injectable } from '@angular/core'; import { MainDataService } from '../maindata/maindata.service'; @Injectable({ providedIn: 'root' }) export class KbDetectionService { private keyPressSpeeds: number[] = []; constructor( private mainDataService: MainDataService ) { } pushKeyPressSpeeds(speed: number): void { this.keyPressSpeeds.push(speed); Iif (this.keyPressSpeeds.length === 10) { const sumKeyPressSpeeds = this.keyPressSpeeds.reduce((x: number, y: number) => x + y); const averageKeyPressSpeed = sumKeyPressSpeeds / this.keyPressSpeeds.length; if (averageKeyPressSpeed < 50) { this.mainDataService.isExtendedKbUsed = false; } else { this.mainDataService.isExtendedKbUsed = true; } } } } |