Cursor

The Clipboard Aptitude provides the ability to retrieve information about the user's cursor.

listenPosition

Starts listening to changes to the cursor position. Takes a callback function as an argument, which sends a Position whenever called. A promise is triggered after setting the listener that provides access to a Cancellable stream, so that you can turn off the listener.

import { cursor } from '@oliveai/ldk';

let cursorStream: Cancellable;

cursor.listenPosition((position) => {
    console.log(`Cursor position: ${position.x}/${position.y}`);
}).then((cancellable: Cancellable) => {
    cursorStream = cancellable;
});

position

Retrieves the cursor's current position.

import { clipboard } from '@oliveai/ldk';

// Function that is called after position() is successful
// Provides the cursor's position when position() was executed
const callback = (position) => {
    console.log(`Cursor position: ${position.x}/${position.y}`);
};

clipboard.position().then(callback);

Last updated