我如何获得我在Google搜索栏上输入的文本,例如react Native

发布于 2025-02-14 01:49:14 字数 97 浏览 0 评论 0原文

实际上,当我想在Google搜索栏上输入时,我想构建可以捕获所有击键的东西。这可以在React Native中构建吗?没有我自己的键盘。它应该像钥匙记录员一样从任何地方获得任何输入

Actually, I want to build something that can catch every keystroke when I want to type on the google search bar. is that possible to build in react native? without my own keyboard. it should get any input from anywhere like a keylogger

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

淡淡的优雅 2025-02-21 01:49:14

也许您可以尝试收听输入的更改事件
例如:

let input = document.getElementById('myinput');
input.addEventListener('change', e => {
    let value = e.target.value;
    console.log('value',value);
});

maybe you can try listen change event of input
for example:

let input = document.getElementById('myinput');
input.addEventListener('change', e => {
    let value = e.target.value;
    console.log('value',value);
});
献世佛 2025-02-21 01:49:14

如果您希望输入在输入时更改,则应按照这样的措施进行操作:

const [input, setInput] = useState('');

    <TextInput
      style={styles.input}
      onChangeText={text => setInput(text)}
      value={input}
      placeholder="input some text"
      placeholderTextColor="gray"
    />

这将使之成为现实,以便每个按键都会更新Input,并删除曾经写过的内容。

您还应该在提交按钮或search按钮中具有更清洁的逻辑,以将输入重置为空字符串'',以便您不是剩下以前的文本,必须每次删除IR。这样的事情:

onPress={() => {
//your submit trigger
setInput('');
}}

if you want your input to change as you type then you should follow something like this:

const [input, setInput] = useState('');

    <TextInput
      style={styles.input}
      onChangeText={text => setInput(text)}
      value={input}
      placeholder="input some text"
      placeholderTextColor="gray"
    />

This will make it so every keystroke will update the input as well as deleting what was once written on it.

You should also have a cleaner logic in your submit button or search button to reset the input to an empty string again '' so you are not left with the previous text and having to delete ir every time. Something like this:

onPress={() => {
//your submit trigger
setInput('');
}}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文