INTRODUCTION
Recent advances in artificial intelligence have expanded the range and accessibility of machine-learning applications, while also creating new cybersecurity risks (Guembe et al., 2022). Side-channel attacks exploit information leaked during a system’s operation without directly breaching its intended security mechanisms (Standaert, 2010). We focus on optical keystroke inference, a side-channel attack that uses recorded keyboard activity to infer typed input. We examine the use of vision-based ML techniques for automated visual hacking, where passive video collection of keystrokes is used for data extraction.
Prior studies have demonstrated video-based keystroke inference under different recording conditions (Balzarotti et al., 2008; Yang et al., 2023). These findings raise concerns about activities such as banking or professional communication conducted within view of recording devices, including cameras installed for security rather than keyboard analysis. AI-enabled surveillance raises concerns regarding privacy, autonomy and governance. Privacy is recognized by the United Nations as a human right, and side-channel attacks complicate the protection of this right as they can derive sensitive information from seemingly innocuous data (Office of the United Nations High Commissioner for Human Rights, 2021). One difficulty is that information legitimately recorded for one purpose may later be analyzed to infer something not expected by the person recorded. Nissenbaum’s (2004) account of contextual integrity distinguishes the collection of information from the appropriateness of its subsequent use. A visible security camera does not establish consent for the inference of keyboard input from its recordings, particularly when the person observed has no reason to anticipate such analysis.
The unequal distribution of surveillance authority also shapes the practical costs of protecting privacy. Research on privacy and marginalized groups has documented how protecting personal information entails different costs across social contexts (Sannon & Forte, 2022). In a study of German workplaces, Abendroth et al. (2026) found that employees in lower-status jobs experienced more invasive forms of digital monitoring than those in resource-rich positions. These findings establish that the distribution of monitoring is shaped by institutional and occupational power. Journalists, activists, whistleblowers, and others handling sensitive information may face heightened risks in politically restrictive environments. Qualitative research in Uganda and Zimbabwe has linked state surveillance to self-censorship and constraints on expression and assembly (Murray et al., 2024).
These inequalities make control over recorded footage consequential when additional information can be extracted from it. The resources required for successful inference determine how readily recorded keyboard activity can be analyzed. We therefore examine the technical barriers to optical keystroke inference using public tools and modest computational resources. Our methodological choices drew on earlier work in optical keystroke inference.
First, keystroke labels were often restricted to the 26 letters and a few additional tokens (Lim et al., 2022), and thus we adopted this design. Second, video interpretation was approached using frame-by-frame analysis, whereby each frame was independently input for an NN (Balzarotti et al., 2008). Following this approach, we framed the task as a supervised classification problem, where individual frames served as inputs and the model was trained to produce a corresponding label. Although prior work reported strong results using extensive preprocessing (Yang et al., 2023), we omitted this design decision to preserve the simplicity of our baseline model.
Another study attempted optical flow analysis, where instead of a single-frame input, a sequence of frames is analyzed to provide temporal context. The study reported poor results, citing noise and the complexity of typing patterns as limiting factors (Balzarotti et al., 2008). This was unintuitive, as such NNs have been documented to be well-suited for video analysis (Byeon et al., 2015), with one study examining a task adjacent to ours reporting improvement using them (Alsharif et al., 2015). We therefore tested whether temporal context improved classification under our recording and data constraints. We constructed a simplified NN pipeline to examine the feasibility of this attack.
Model hyperparameters are the initial configuration of the architecture set prior to training (Liao et al., 2022). Our experiments explore limitations and compare hyperparameters as we build the pipeline from the ground up, providing a realistic case study of what an adversary with modest resources can optimally achieve using only publicly available tools and data. We aim to establish a lower-bound threat by showing that partial keystroke inference can be achieved within a controlled environment using widely accessible resources. This distinction is important because the societal risk may arise not only from highly accurate systems operated by sophisticated actors, but also from the diffusion of imperfect yet inexpensive inference capabilities that can be adapted to particular targets or environments.
Our hypothesis was that a suitably generalized model can be trained from a limited dataset, using an unsophisticated model and modest computational resources. We define suitably generalized as a model that can perform well with fresh test data, using F1 score as the performance metric (Diallo et al., 2025), as discussed in the next section. A limited dataset is defined as a video dataset that has a total length of less than 2 hours, derived from existing literature (Yang et al., 2023). This is an operational threshold, not an estimate of the amount of suitable footage available to an adversary. An unsophisticated model refers to one that comprises just the NN, without significant preprocessing or a complex pipeline (Balzarotti et al., 2008; Lim et al., 2022; Yang et al., 2023). We chose to define modest computational resources as publicly accessible cloud notebook hardware, specifically Kaggle hardware, rather than dedicated high-end research clusters.
MATERIALS AND METHODS
The dataset used in this study was “Keystroke-Typing-Videos”, sourced from Hugging Face (andrewt28, 2025). The dataset was published in 2025 by user Andrew Tran and comprised 800 videos with a mean video length of ~6.73 seconds. In total, there were 158,854 frames and 40,862 keystrokes. The data also provided a keystrokes array, indicating the key pressed and millisecond timestamp data, which was useful for labeling.
We selected this dataset for its consistent recording conditions. The video data had the same typist, a consistent keyboard, and a consistent camera angle. Lighting was also largely consistent. Keeping these other factors controlled was imperative to ensure the prospective NN trained on such a dataset would only generalize based on hand placement. We separated the dataset into 620 videos for training, 120 videos for validation, and 60 videos for testing. The dataset presented three limitations. First, it was far from evenly distributed in terms of keystroke types. Across 72 classes, the difference between most and least common classes was 89209 frames: ‘nothing’ had 89210 frames, while ‘colon’ had only 1 frame. This was a significant concern, as with such low numbers of samples for certain classes, the model was unlikely to be able to generalize features for them. Second, the videos were far larger in terms of storage usage than necessary. Much of each frame was redundant pixel data that did not contribute to the features needed to discern keystrokes. Third, we observed seemingly random delay between the timestamp indicated on keystroke event labels, and the actual frames where keystrokes occurred. We termed this phenomenon “frame-label mismatch.” Variable frame rate or timestamp handling may have contributed (Madhusudana et al., 2022), but we did not isolate the cause experimentally.
The following data preparation steps were used to counter these limitations. Each frame had three red-green-blue (RGB) channels comprising integers from 0–255. This required normalization, the mapping of values to a 0–1 floating representation. We considered two approaches: min-max normalization, achieved by dividing each value by 255, and z-score normalization, in which values are scaled to have zero mean and unit variance (Haseeb et al., 2024). We evaluated both approaches in our experiment #1.
The image was downsampled by a factor of 0.5, reducing resolution. Next, it was cropped, then converted into a single-channel grayscale image, before being contrast-boosted. This was to limit input dimensionality, which is the size of the input, so as to filter out redundant data and improve the prospective NN’s ability to extract features (Lecun et al., 1998; Stojnev & Stojnev Ilić, 2020). The transformation was conducted with PyTorch package torchvision.transforms, which provided image processing and augmentation techniques.
We then engaged in data selection to solve the issue of an unbalanced distribution of labels. We merged upper-case and lower-case letter classes and removed rarer classes such as certain punctuation; we had 37 classes remaining. This replicated the restricted number of classes used in similar literature (Lim et al., 2022). We also removed a large quantity of frames from classes that oversaturated the dataset via random undersampling, to improve class balance, countering the first dataset limitation.
This data transformation and selection reduced dataset size from 58.31 gigabytes to 6.38 gigabytes, countering the second dataset limitation. The impact of this data transformation and selection was evaluated in experiment #2. Data labeling was implemented in three different methods. The first method, tagging the nearest frame to each recorded keystroke event, was the standard for all experiments excluding experiments #3 and #4. This was simple to execute due to the provided keystrokes array.
The second method, temporal frame stacking, was informed by earlier work on motion cues (Balzarotti et al., 2008). Three sequential frames were input together with one label to introduce time context in experiment #3. This was conducted by splitting the dataset into overlapping sets of three frames, with the center frame being where the keystroke occurred. Our hypothesis was that this brief amount of time context would help the model better generalize keystrokes as it could extract information such as the previous and future positions of the fingers to gauge travel.
The third method, generous labeling, in which multiple frames were labeled per keystroke, was used in experiment #4. This means for a given keystroke, as many as three frames would be labeled with that keystroke instead of just one. We hypothesized that with generous labels, the impact of frame-label mismatch would be minimized, since keystrokes that occurred a temporal distance away from the attached timestamp would still be correctly labeled.
We considered five models: EfficientNet_b0, ResNet18, MobileNetV2_100, ConvNeXt_Tiny, and a Feed-Forward architecture (He et al., 2016; Liu et al., 2022; Sandler et al., 2018; Tan & Le, 2019). The first four are convolutional neural network (CNN) architectures—specialized NNs designed for image feature extraction using sliding kernels (Lecun et al., 1998). CNNs use filters to scan across images for local spatial patterns, such as edges or textures, which could improve hand-typing movement recognition.
The feed-forward NN was included as a baseline. This is an architecture also called a Multi-Layer Perceptron (MLP), the earliest form of artificial NNs (Rumelhart et al., 1986). The architectures were selected for different purposes: EfficientNet_b0 provides balance of network depth and speed; ResNet18 provides industry-standard baseline for stable convolutional performance; MobileNetV2 was to evaluate performance under strict hardware and memory constraints; ConvNeXt_Tiny represents modern highly optimized image networks; and the feed-forward network provided a baseline for assessing the contribution of convolutional feature extraction.
Additional architecture hyperparameters were considered. Experiment #6 evaluated using pretrained CNN models versus non-pretrained CNN models. Pretraining refers to CNNs that have already been trained on a large general dataset to learn foundational patterns. We also considered freezing layers when fine-tuning pretrained networks (Goutam et al., 2020).
Experiment #7 evaluated class-balanced training, where loss contribution of each sample is scaled by a weight inversely proportional to its class frequency. This means that the model penalizes errors on rare classes more heavily than errors on common ones, ensuring that majority classes do not dominate the learning process. This was chosen due to the class-imbalanced nature of the dataset. Experiment #8 examined the value of a hidden layer, where a hidden fully connected layer of size 512 units was introduced in the model, to account for more complex feature extraction.
Experiment #9 considered a dropout rate of 0.4, a regularization technique where during training a random 40% selection of neurons are set to zero, preventing the NN from relying on certain pathways. This was an attempt to mitigate overfitting and promote generalization. Overfitting is when the NN begins to memorize specific training samples and their associated noise instead of learning generalizable features, thus compromising performance on unseen data. Experiment #10 evaluated the learning-rate (LR) scheduler. LR is a hyperparameter that controls how drastically the model updates its weights in response to error. Time-based scheduler, where LR is decreased over time, was evaluated against progress-based scheduler, where LR decreases only with plateauing performance.
We recorded training loss, validation loss, and validation accuracy during training, and used F1 score as the primary performance metric. Training loss, which measures the average error of the model’s predictions on the training data, was used to observe speed of convergence. Convergence is the point at which the model stabilizes and reaches an optimal state where further epochs yield no significant reduction in loss.
Validation loss, the error calculated on a separate dataset not trained on, was used as an indicator of overfitting.
Validation accuracy, representing the percentage of correctly classified instances in the validation set, was a rough indicator of performance (Arora et al., 2018; Li et al., 2024; Taheri & Thrampoulidis, 2023).
Final evaluation of performance was based on F1 score, defined as the harmonic mean of precision (the proportion of positive predictions that were correct) and recall (the proportion of actual positives that were correctly identified) for each class. F1 score complements accuracy in imbalanced classification because a high accuracy can obscure errors on less frequent labels. Its interpretation still depends on class-wise performance and the method used to average scores (Riyanto et al., 2023).
RESULTS
We trained 26 models across ten experiments for 60–100 epochs using a Kaggle NVIDIA Tesla P100 GPU with 16 GB VRAM and eight vCPUs. Training required 75 hours in total, with individual runs lasting 2–13 hours. We report detailed findings for experiments #3, #4, and #5, which examine temporal context, label assignment, and model architecture, respectively. We then summarize the results across all ten experiments.
Time context led to faster convergence to a lower training loss value. However, validation loss curves reveal that models trained with time context, regardless of pretraining, overfit several epochs earlier around epoch 9 compared to epoch 11. This earlier onset of overfitting likely accounts for the lower training loss observed. F1 scores show that time-context-informed models perform worse than non-time-informed models. The peak F1 score is attained by the pretrained ResNet without time context, a value of 0.521. Time context nevertheless increased validation accuracy: from 0.453 to 0.459 for the non-pretrained ResNet, and from 0.467 to 0.480 for the pretrained.
Generous labels allowed for faster convergence of training loss, while converging to approximately a similar loss level as the model trained on non-generous labels. Models trained on generous labels began overfitting earlier, around epoch 6 versus epoch 11. However, models trained on generous labels overfit to a lesser degree, seen by how the steady state of validation loss was lower at 2.4 for these models than those trained without generous labels at 2.6. Models trained on generous labels perform better, both in terms of validation accuracy and F1 score. The model trained on generous labels has a peak F1 score of 0.513 compared to 0.499 for the model trained on non-generously labeled data.
EfficientNet demonstrated the fastest convergence of training loss, while the Feed-Forward network exhibited slow and shallow convergence. EfficientNet and ConvNeXt converged at a training loss of 0.72, compared with 0.76 for ResNet and MobileNet and 1.66 for the feed-forward model. Considering validation loss, EfficientNet began overfitting first, at epoch 10, with the other CNN models following in the subsequent epochs, while the feed-forward model’s validation loss did not display signs of overfitting.
F1 score identifies MobileNet as the best performer. The feed-forward network attained a relatively high peak validation accuracy despite its low peak F1 score, at 0.463, higher than all the CNN models. Overall, as F1 score is our primary metric, MobileNet is the best performer with a peak F1 score of 0.510.
A synthesis of results from all 10 experiments found that the highest-scoring combination among the hyperparameters we evaluated was the following: a model trained on a dataset that was min-max normalized, transformed, lacked time context, and was generously labeled; the architecture used was a pretrained MobileNetV2_100, with class-balanced training, a hidden layer, a dropout rate of 0.4, and a time-based learning-rate scheduler. A synthesis model was created using these hyperparameters, resulting in superior model performance compared to all other trained models, with a peak F1 score of 0.542 and a peak validation accuracy of 0.495.
DISCUSSION
Experiment #3 results reflected that time context led to a lower F1 score but higher validation accuracy. We suggest this indicates time-context-informed models have an improved ability to learn common patterns, but an inferior ability to generalize classes with lower representation. We hypothesize that time-context-informed training requires larger quantities of data, and thus only performs well for classes with larger representation within the dataset. This should be verified with larger and better-time-aligned datasets.
Experiment #4 results show that generous labels improve model performance in terms of F1 scores and validation accuracy. Generous labels seem to achieve results in line with our hypothesized improvements, appearing to help partially mitigate frame-label mismatch.
Experiment #5 results suggest that CNNs—particularly MobileNetV2—are more suitable for vision-based keystroke classification. The feed-forward model’s comparatively high validation accuracy but low F1 score suggests reliance on frequent classes rather than generalizable spatial features. Its higher training loss further indicates underfitting. Together, these results support the importance of convolutional spatial feature extraction for this task.
Considering the overall results, we achieved partial frame-level keystroke classification with a limited dataset, an uncomplicated model, and modest computational resources.
While the results obtained were satisfactory, it is evident that we were unable to reproduce the impressive results seen in existing literature (Balzarotti et al., 2008; Lim et al., 2022). We hypothesize this is largely due to the major limitation of frame-label mismatch present in our dataset.
Although our generous labeling approach improved performance by correctly labeling frames with keystroke events, it also increased the number of mislabeled non-keystroke frames, reducing the overall improvement. This is because while previously three sequential frames might have contained one keystroke frame that was correctly labeled, now all three frames would be given that same label, giving rise to two “nothing” frames that are mislabeled as keystroke events.
This is a likely reason why generous labeling was not a complete solution to the problem. Furthermore, this raises the concern that the documented improvement may not be due to improved generalization, but instead looser validation criteria. The validation dataset is also generously labeled, and so instances of mislabeling certainly occurred. This likely inflated performance metrics as the model received credit for incorrect predictions on mislabeled frames. This introduces inaccuracies and complicates the interpretation of F1 scores. In conclusion, this method of generous labels we used to combat this limitation is, itself, severely limited. However, we could not produce alternative methods, other than manual relabeling of the dataset which we lacked the time and personnel to conduct.
Our analysis of frame-label mismatch highlights a potential practical limitation for adversaries, particularly in attacks employing commercial cameras. The proposed reasons for this limitation, as outlined above, also apply to any other attack vector involving commercial cameras (Usach et al., 2009). Thus, bad actors may be unlikely to be able to obtain perfectly aligned frame-label pairs from covert passive video collection.
Keyboard angle, lighting, compression artifacts, and other variation in passive video collection were largely controlled for in this experiment. We therefore cannot infer the performance of the model under substantially different recording conditions. Prior work has investigated more elaborate processing pipelines (Yang et al., 2023), but their results do not establish the transferability of the model tested here.
The practical significance of these recording constraints also depends on who controls collected footage and its subsequent use. Our findings align with research suggesting that ML automation can reduce the expertise, time, and financial resources required for malicious attacks, weakening the traditional trade-off between scale and effectiveness (Brundage et al., 2018). By demonstrating partial inference using accessible tools, this study indicates that surveillance capabilities may diffuse beyond well-resourced actors. Potential misuse also extends to institutions holding large video datasets. Footage collected for one purpose may subsequently be analyzed for a different purpose, creating questions of consent and the limits of secondary use (European Data Protection Board, 2020; Nissenbaum, 2004). Institutional or commercial use should therefore be constrained by purpose limitation, data minimization, strict retention, and access controls.
Control over surveillance is frequently asymmetrical. Organizations decide where cameras are placed, how long footage is stored, and whether additional analysis is performed; individuals recorded in shared workplaces or facilities may have limited opportunities to decline observation. Sannon et al. (2022) found that surveillance and platform power shape privacy decisions. Technical capability therefore provides only part of the account of privacy risk. Liang et al. (2023) found that workers demanded higher compensation for digitally monitored jobs in experiments conducted on two online labor platforms. Disclosure did not eliminate concerns about intensive monitoring. The costs of surveillance therefore extend beyond information security to the economic choices available to those subject to it.
Greenleaf (2025) documented national data-protection legislation in 172 countries and identified updating existing laws as an increasing priority. The presence of legislation does not guarantee uniform rules or effective enforcement. For footage capable of revealing typed information, practical protection depends on legal restrictions on secondary use, institutional compliance, and access to remedies. The European Data Protection Board’s (2020) guidance provides an example of requirements relevant to camera operators, including purpose specification, limits on retention, and scrutiny of further processing. Rights to contest subsequent analysis and seek redress depend on enforceable rules and institutional practice. The availability of these protections determines the practical value of privacy legislation.
As optical keystroke inference is a dual-use capability, dissemination also requires ethical judgment. Openness can support reproducibility and defensive research, but releasing trained weights or turnkey procedures may lower barriers to misuse; researchers should therefore assess foreseeable benefits and harms when deciding what to publish (Bailey et al., 2012).
Responsibility for preventing misuse cannot rest with the person recorded alone. Camera operators control retention, access, and subsequent analysis; developers can consider foreseeable misuse when designing analytic systems; and regulators can establish standards for transparency and accountability. The Office of the United Nations High Commissioner for Human Rights (2021) identifies due diligence, transparency, and effective remedies as responsibilities across the life cycle of AI systems. These principles provide a basis for limiting secondary analysis of footage and assigning accountability for misuse.
We provide a resource-constrained comparison of hyperparameters for optical keystroke inference, and identify frame-label mismatch as a practical limitation of video-based attacks. Our results also suggest that temporal models may require larger and more accurately aligned datasets than single-frame models. Future work should evaluate these findings across users, keyboards, camera conditions, and preprocessing budgets, while considering the social implications of such attack vectors.
CONCLUSION
Results indicate partial keystroke inference under the controlled recording conditions tested, though performance remains far from reliable full-text reconstruction. Importantly, our findings suggest that such attacks could be mounted even by adversaries with limited resources or expertise, underscoring the need for further research into countermeasures and privacy-preserving defenses.
Our findings inform research into optical keystroke-inference capabilities and the development of privacy-preserving countermeasures. We raise questions about how design decisions, institutional incentives, and regulatory systems affect control over surveillance capabilities, including whether protective burdens fall unevenly. Studies of German workplaces and surveillance in Uganda and Zimbabwe document unequal monitoring conditions and distinct consequences for those subject to surveillance (Abendroth et al., 2026; Murray et al., 2024). We recommend that researchers, governments, technology companies, affected communities, and civil-society organizations jointly develop rights-based safeguards. From a global justice perspective, the implications extend beyond technological vulnerability to fundamental questions of power, human dignity, and the unequal distribution of surveillance risks, particularly for individuals and communities with limited capacity to challenge institutional monitoring or secure meaningful protection of their privacy rights. The challenge is to preserve the defensive and scientific value of AI research without normalizing low-cost surveillance or shifting the burden of privacy protection onto those least able to bear it.
ACKNOWLEDGMENTS
We would like to express sincere gratitude to Leonard Gleyzer for their guidance and constructive feedback throughout this project. We also wish to thank our peers for their insightful discussions, which helped shape the direction of this research.
This work made extensive use of open-source tools, including PyTorch and Hugging Face Datasets, without which this study would not have been possible. We are also grateful to Google’s Kaggle platform for providing computational resources that enabled the training and evaluation of our models.
Conflicts of Interest
We declare no conflicts of interest.
Ethical Approval Statement
This study involved secondary analysis of a publicly available video dataset. No participants were recruited or recorded.



