{"id":20596020,"url":"https://github.com/davidfig/input","last_synced_at":"2025-04-14T23:44:14.358Z","repository":{"id":57404898,"uuid":"104710989","full_name":"davidfig/input","owner":"davidfig","description":"basic input support for touch, mouse, and keyboard","archived":false,"fork":false,"pushed_at":"2017-12-29T00:42:41.000Z","size":409,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-28T11:51:08.686Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidfig.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-09-25T06:22:20.000Z","updated_at":"2022-03-31T17:01:17.000Z","dependencies_parsed_at":"2022-09-03T16:21:31.651Z","dependency_job_id":null,"html_url":"https://github.com/davidfig/input","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Finput","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Finput/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Finput/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidfig%2Finput/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidfig","download_url":"https://codeload.github.com/davidfig/input/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248863338,"owners_count":21173982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T08:14:48.142Z","updated_at":"2025-04-14T23:44:14.329Z","avatar_url":"https://github.com/davidfig.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yy-input\nbasic input support for touch, mouse, and keyboard\n\n## rationale\n\nI used this in all my games, so I decided to centralize and share it. This is a very simple class that emits events after a touch, mouse, or keyboard event. The events are tied to an HTMLElement.\n\n## installation\n\n    npm i yy-input\n\n## simple example\n\n    const Input = require('yy-input')\n\n    this.input = new Input()\n    this.input.on('down', \n        function down(x, y)\n        {\n            console.log('You clicked at ' + x + ', ' + y)\n        })\n\n## live example\nhttps://davidfig.github.io/input/\n\n## API\n```js\n    /**\n     * basic input support for touch, mouse, and keyboard\n     *\n     * @param {object} [options]\n     * @param {HTMLElement} [options.div=document] object to attach listener to\n     * @param {boolean} [options.noPointers] turns off mouse/touch/pen listeners\n     * @param {boolean} [options.noKeyboard] turns off key listener\n     * @param {boolean} [options.chromeDebug] ignore chrome debug keys, and force page reload with ctrl/cmd+r\n     * @param {number} [options.threshold=5] maximum number of pixels to move while mouse/touch downbefore cancelling 'click'\n     * @param {boolean} [options.preventDefault] call on handle, otherwise let client handle\n     *\n     * @event down(x, y, { input, event, id }) emits when touch or mouse is first down\n     * @event up(x, y, { input, event, id }) emits when touch or mouse is up or cancelled\n     * @event move(x, y, { input, event, id }) emits when touch or mouse moves (even if mouse is still up)\n     * @event click(x, y, { input, event, id }) emits when \"click\" for touch or mouse\n     * @event wheel(dx, dy, dz, { event, id, x, y }) emits when \"wheel\" scroll for mouse\n     *\n     * @event keydown(keyCode:number, {shift:boolean, meta:boolean, ctrl: boolean}, { event, input }) emits when key is pressed\n     * @event keyup(keyCode:number, {shift:boolean, meta:boolean, ctrl: boolean}, { event, input }) emits when key is released\n     */\n    constructor(options)\n\n    /**\n     * remove all listeners\n     */\n    destroy()\n\n    /**\n     * turns on pointer listeners (on by default); can be used after removePointers()\n     */\n    addPointers()\n\n    /**\n     * remove pointers listener\n     */\n    removePointers()\n\n    /**\n     * turns on keyboard listener (off by default); can be used after removeKeyboard()\n     */\n    addKeyboard()\n\n    /**\n     * removes keyboard listener\n     */\n    removeKeyboard()\n\n```\n## License  \nMIT License  \n(c) 2017 [YOPEY YOPEY LLC](https://yopeyopey.com/) by [David Figatner](https://twitter.com/yopey_yopey/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfig%2Finput","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidfig%2Finput","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidfig%2Finput/lists"}