Code Monkey home page Code Monkey logo

typingdnarecorder-java's Introduction

TypingDNARecorder JAVA

A simple way to capture user’s typing patterns in JAVA

Compatible with JavaSE (awt) and JavaFX

Usage and description

First you need to add com.typingdna to your Built Path and import com.typingdna.TypingDNARecorder class in the app that wants to record a typing pattern. You will need to record typing patterns when a user first creates his account and again whenever you want to authenticate that user on your platform.

TypingDNARecorder class

Once you create an instance of the TypingDNARecorder class, you need to overwrite the functions for handling key events in specific text fields. All functions you need to call are static.

Note that implementation of these events is a bit different in JavaSE and JavaFX due to the way these deal with KeyEvent objects. Please check the code examples for each.

Example

new TypingDNARecorder();

textMain.addKeyListener(new KeyAdapter() {
    public void keyPressed(KeyEvent e) {
    	int keyCode = e.getKeyCode();
        int keyChar = e.getKeyChar();
      	boolean modifiers = (e.getModifiers() == 1);
    	TypingDNARecorder.keyPressed(keyCode, keyChar, modifiers);
    }
    public void keyTyped(KeyEvent e) {
    	int keyChar = e.getKeyChar();
    	TypingDNARecorder.keyTyped(keyChar);
    }
    public void keyReleased(KeyEvent e) {
      	int keyCode = e.getKeyCode();
      	boolean modifiers = (e.getModifiers() == 1);
      	TypingDNARecorder.keyReleased(keyCode, modifiers);
    }
});

Whenever you want to get the user's typing pattern you have to invoke TypingDNARecorder.getTypingPattern() method described in detail below.

TypingDNA.getTypingPattern(optionsObject)

This is the main function that outputs the user's typing pattern as a String

Returns: A typing pattern in String form

Input params: the following params are required: type, length, text, textId, extended (in this particular order). Detail table below.

Param Type Description
type int 0 for anytext pattern (when you compare random typed texts of usually 120-180 chars long)
1 for diagram pattern (recommended in most cases, for emails, passwords, phone numbers, credit cards, short texts)
length int (Optional) the length of the text in the history for which you want the typing pattern, 0 = ignore, (works only if text = "")
text String (Only for type 1) a typed string that you want the typing pattern for
textId int (Optional, only for type 1) a personalized id for the typed text, 0 = ignore
extended boolean (Only for type 1) specifies if full information about what was typed is produced, including the actual key pressed, if false, only the order of pressed keys is kept (no actual content)

Example

int type = 1;
int length = 0;
String text = textMain.getText();
int textId = 0;
boolean extended = true;

String typingPattern = TypingDNARecorder.getTypingPattern(type, length, text, textId, extended);

TypingDNARecorder.reset()

Resets the history stack of recorded typing events.

TypingDNARecorder.start()

Automatically called at initilization. It starts the recording of typing events. You only have to call .start() to resume recording after a .stop()

TypingDNARecorder.stop()

Ends the recording of further typing events.

License

Apache License, Version 2.0

typingdnarecorder-java's People

Contributors

endresstefan avatar

Watchers

James Cloos avatar Sandipan Banerjee avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.