@HostListener('keydown', ['$event', '$event.keyCode'])
onKeyDown($event: KeyboardEvent, keyCode) { if(keyCode !== TAB) {
$event.preventDefault();
} // get value for the key
const val = String.fromCharCode(keyCode);
// get position
const cursorPos = this.input.selectionStart; overWriteCharAtPosition(this.input, val, cursorPos);
} export const overWriteCharAtPosition = (
input: HTMLInputElement,
val: any,
position: number
) => {
const currentValue = input.value;
input.value = currentValue.slice(, position) + val + currentValue.slice(position+);
};

[Angular HTML] Overwrite input value, String.fromCharCode & input.selectionStart的更多相关文章

  1. Android input输入框 移动页面input手机键盘中的“搜索”按键

    动页面input手机键盘中的“搜索”按键 满足以下几点机即可: input type="search"    放到form标签中    使用action属性 <form ac ...

  2. 封装input 逐渐,且input插件必须带有默认值。

    封装input 逐渐,且input插件必须带有默认值. 组件: <template> <div class="input-show"> <span c ...

  3. 数组乘积--满足result[i] = input数组中除了input[i]之外所有数的乘积(假设不会溢出

    数组乘积(15分) 输入:一个长度为n的整数数组input 输出:一个长度为n的整数数组result,满足result[i] = input数组中除了input[i]之外所有数的乘积(假设不会溢出). ...

  4. Oracle delete input与delete all input

    oracle官方文档提示:If you had specified DELETE INPUT rather than DELETE ALL INPUT, then RMAN would have on ...

  5. input type类型和input表单属性

    一.input type类型 1.Input 类型 - email 在提交表单时,会自动验证 email 域的值. E-mail: <input type="email" n ...

  6. 定制 input[type="radio"] 和 input[type="checkbox"] 样式

    表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...

  7. 修改 input[type="radio"] 和 input[type="checkbox"] 的默认样式

    表单中,经常会使用到单选按钮和复选框,但是,input[type="radio"] 和 input[type="checkbox"] 的默认样式在不同的浏览器或 ...

  8. angular自定义指令解决IE89不支持input的placeholder属性

    下面代码实测通过,直接copy到本地运行即可. <!DOCTYPE html> <html> <head> <meta charset="UTF-8 ...

  9. How to Construct the Input Bet String

    The purpose of this section is to describe the format of the string which will submitted to the Pyth ...

随机推荐

  1. ElasticSearch指南

    ElasticSearch快速指南 ElasticSearch是基于Apache Lucene的分布式搜索引擎, 提供面向文档的搜索服务. 安装ElasticSearch 文档 创建文档 访问文档 更 ...

  2. vue (v-if show 问题)

    vue中的显示和隐藏有两种方式 1.v-if   ( 相当于动态创建的标签,在html 结构中,是不存在的. ) 2. v-show(控制的是 html 的css display:none  属性.结 ...

  3. 62.C++文件操作list实现内存检索,实现两千万数据秒查

    1 #include <iostream> #include <fstream> #include <cstdlib> #include <string> ...

  4. GridView1.DataKeys[e.RowIndex].Value 是什么含义?

    https://zhidao.baidu.com/question/88518619.html举个例子来说吧 你将一个student表绑定到grid上 这个表里有一些字段 包括id 姓名 学号 等等等 ...

  5. HDU 4699 Editor 维护栈

    维护两个栈,分别存光标前和光标后的数 再维护前缀和的栈 和 前缀和最大值的栈 注意一下左移,右移,删除到顶了就不操作了 5个操作 I x : 光标处插入x  -----> s1.push(x) ...

  6. 微信小程序从零开始开发步骤(一)搭建开发环境

    从零到有写一个小程序系列专题,很早以前就想写来分享,但由于项目一直在进展,没有过多的时间研究技术,现在可以继续分享了. 1:注册 用没有注册过微信公众平台的邮箱注册一个微信公众号, 申请帐号 ,网址: ...

  7. bash的启动文件

    文件名称 功能描写叙述 /etc/profile 登录时自己主动运行 ~/.bash_profile,~/.bash_login,~/.profile 登录时自己主动运行 ~/.bashrc shel ...

  8. 27.mutex跨进程通信

    创建互斥量mutex HANDLE mutex = CreateMutexA(NULL, TRUE, name); 根据id打开mutex HANDLE mutex = OpenMutexA(MUTE ...

  9. 78.pipe多管道云端,客户端通信

    压力测试截图: 云端 定义管道缓存区大小,最多连接数量(线程个数),当前线程个数,管道名字 //缓冲区大小 #define SIZE 4096 //最多连接数量 #define MAX_CONNECT ...

  10. 轻松学习Linux之Shell的常用过滤器

    下载高清视频: http://down.51cto.com/data/157818    大小3:MB      时长: 7分钟 更多内容见: Linux爱好者的圣诞大餐-轻松学习Linux系列多媒体 ...