Skip to content

g-js-api/input

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@g-js-api/input

A wrapper around the Infinite Inputs Geode mod for G.js, allowing you to detect mouse and keyboard input.

Usage

import '@g-js-api/g.js';
import '@g-js-api/input';

await $.exportConfig({
    type: 'live_editor',
    options: {
        info: true
    }
})

// object that follows the cursor
let cursor = unknown_g();
lock_to_mouse(cursor);
object({
    OBJ_ID: 211,
    GROUPS: cursor,
    HIDE: true
}).add();

// draggable button
let drag = button({
    x: 45, y: 45
});
// when the mouse is pressed down, make the button follow the mouse
drag.onmousedown = trigger_function(() => {
    trigger({
        OBJ_ID: 3016,
        TARGET: drag.object,
        FOLLOW: cursor
    }).add();
})
// when the mouse is released, stop making the button follow the mouse
drag.onmouseup = trigger_function(() => {
    drag.onmousedown.stop();
})

// start listening for all button events (added as an Input trigger)
drag.listen();

// flash the BG red when the user presses the letter K
on(key("K"), trigger_function(() => {
    log.runtime.flash(rgb(255, 0, 0));
}));

// flash the BG magenta when the user presses Ctrl + A
on(shortcut('Ctrl + A'), trigger_function(() => {
    log.runtime.flash(rgb(255, 0, 255));
}));

// flash the BG cyan when the user right clicks
on(rightClick(), trigger_function(() => {
    log.runtime.flash(rgb(0, 255, 255));
}));

Docs

comig soom

About

A wrapper around the Infinite Inputs Geode mod for G.js, allowing you to detect mouse and keyboard input.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors